I want to display total post where like is 3 or more;
I have 3 table
Table post:
id_post | title
1 | Ganteng
2 | serigala
Table User
id_user | username
1 | mantan
2 | otong
3 | pak_pol
Table vote:
id_vote | id_post | LIKE | id_user
1 | 1 | 1 | 2
2 | 1 | 1 | 1
3 | 1 | 1 | 3
4 | 2 | 1 | 1
5 | 2 | 1 | 2
6 | 2 | 1 | 3
Here is my query:
$sql="SELECT COUNT(v.id_post) as total_post
FROM vote v
LEFT JOIN post p ON p.id_post=v.id_post
HAVING SUM(`like`) >= 3";
In my expectation, the value of $sql should be 2... But the return of value is 6
Any answer?
Many thanks