February 6th, 2013, 04:51 AM
Join Date: Jul 2005
Time spent in forums: 1 Day 6 h 47 m 25 sec
Reputation Power: 9
JOIN count wont show items with 0 results
I've been playing around with this query to get a count of then number of times a particular tag occurs in a relational table.
I have 2 tables
Here is the I've come up with
SELECT * FROM (SELECT T.tag, COUNT(C.tag_id) AS num FROM tags T JOIN comment_tags C ON T.id = C.tag_id GROUP BY T.tag) AS A WHERE A.tag LIKE '%tag%' LIMIT 10
I get the following
What I'm trying to get it
Am I trying to do this the wrong way?
Any help would be appreciated.