I want to understand how the queries are parsed and get a general view about the query execution order in Mysql
I have a table 'Likes', and I want to find the most liked photo,
this query is ok
select photo_id, count(*) as count from likes group by photo_id order by count desc limit 1;
but I wanted to know why this query is given me unwanted results, As if I wrote the query without the having clause at the end, a simple count and group by, not executing the max function, or more likely execute it for each distinct row separately:
select photo_id,count(*) as count from likes group by photo_id having max(count) ;
I read here: MySQL query / clause execution order about the execution order, but why can't I use max inside the having clue?
please share with me a good resource on how to understand Mysql queries if you have one :)