[eluser]Hockeychap[/eluser]
You want to use some conditional logic in you sql statement. The exact statement will depend on your database.
If I've read your email correctly then:
1. You want the count of all tags for each user
2. If there are no tags then you want a count of 0 returned
3. If there is a count of 1 or more then you want the count value returned.
Assuming you're using Mysql your statement should use a left join and a if condition are look something like:
Code:
select t.name,t.user_id, if(it.tag_id is not null, sum(1), 0) as "Items"
from tags as t
left join item_tags as it on ( it.tag_id = t.id) // change to match your table join :)
group by t.name,t.user_id
The logic says, if there is a non-null join (which is what mysql returns when it can find a record on the joined table) add one to the total count (the sum function). If there is a null then return a 0;
Hope this helps
Justin