I want to select all users from my table where access_level_id!=0. I also want to count the number of entries in another table where the user id matches a field (this could be 0 or 100).
I have:
SELECT users.id, count(clients.id) as count FROM $db[users] as users
LEFT JOIN $db[clients] as clients ON users.id=clients.salesrep_id
WHERE users.access_level_id!='0'
This is returning just a single number (17)
GROUP BYas suggested below should do the trick.