I am trying to understand why this query in MySQL does not return any result at all whereas I think it should be returning one row with 0 as the column value
select count(ps.id) as totalcount
from tblpresi ps
inner join users_staging.tbluser u on u.id = ps.userid
where ps.id = 3678
group by ps.id
The same query without the “Group By” works as expected.
Any ideas?
Since you say you expect 1 row with zero count, I assume there is no ps.id of 3678.
If you group-by on an empty result-set, there can be no groups. The group by doesn’t “know” about the where-clause, it’s only looking through the result-set.