I am using following SQL Query:
SELECT `comment`.`id` AS `comment_id` , count( `comment_likes`.`comment_id` ) AS `number_of_likes`
FROM `comment`
LEFT JOIN `comment_likes` ON `comment`.`id` = `comment_likes`.`comment_id`
WHERE `comment`.`id`
IN ( 10, 5, 7, 8, 3, 2, 9 )
GROUP BY `comment`.`id`
Here the result of the query is coming as:
comment_id number_of_likes
2 0
3 1
5 0
7 0
8 0
9 0
10 0
Which I don’t want…? I want the same ordering given where condition i.e. WHERE comment.id
IN ( 10, 5, 7, 8, 3, 2, 9 ).
So I want the result to be like:
comment_id number_of_likes
10 0
5 0
7 0
8 0
3 1
2 0
9 0
Can anyone help me…?
Thanks In Advance…..
Add explicit
ORDER BY. A function that can be helpful isFIELD():