Hey guys,
I wonder how to do the joint count, I've never done this before, I really need help doing this.. any help would be appreciated.
I've got 2 tables as follows;
table1 = id, Qsite, Qkey, Qlinks, Qlocation, ...
table2 = id, Qlink, Qkey
I need to count all the "table2" entries WHERE (table1.Qkey=table2.Qkey) AND (table1.Qlocation='$mylocation')
this is the query I gave a try, but doesn't seem to work at all.. whats wrong with it?
$query = "SELECT p.id, p.Qkey, p.Qlocation, COUNT(c.id) AS XAmount
FROM table1 p
LEFT JOIN table2 c ON p.Qkey = c.Qkey
WHERE p.`Qlocation`='$location'
GROUP BY p.id
ORDER BY p.id DESC";
TIA!