I have the following query:
select
*
from
(
SELECT art_titel as at, COUNT(*) as Number1
FROM artikel_views
WHERE user_id != ''
GROUP BY art_titel
ORDER BY Number1 desc
) as FirstSet
join
(
SELECT art_titel as at, COUNT(*) as Number2
FROM artikel_views
WHERE user_id = ''
GROUP BY art_titel
ORDER BY Number2 desc
) as SecondSet
on FirstSet.at = SecondSet.at
My HTML table:
<table>
<tr>
<td>Art Titel</td>
<td>user_id is NULL</td>
<td>user_id is not NULL</td>
</tr>
<?php while($row = mysql_fetch_assoc($res)) { ?>
<tr>
<td><?php echo $row['at']; ?></td>
<td><?php echo $row['Number2']; ?></td>
<td><?php echo $row['Number1']; ?></td>
</tr>
<?php } ?>
</table>
What i do is taking the values from $row['Number1'] and $row['Number 2'] in combination with the art_titel. The result from this query is not good. I have only the art_titel and art_views from the matches on art_titel in both queries but it's not good. I want all items in both ways.
I have tried also a UNION but is isn't working my way.