I have this MySQL query, seems pretty easy:
SELECT users.nick, users.id, COUNT(pm.id) AS pms
FROM users LEFT JOIN pm ON users.id = pm.touser
WHERE users.id = :id AND pm.read = 0
GROUP BY users.id
What I want to do here is simply count all the PMs that aren’t read (doesn’t have “1” in “read” col). If there are any, query works fine, but when there isn’t any row meeting that condition, it returns nothing.
I spent the last hour looking for solution, but it seems really odd, that it works this way. It should only print “0” while echoing “pms”.
Simply: