Grup sql sorgusu

0 Cevap php

I want to have an only query with 2 queries but i don't know how to start... My queries count the positive/negative votes for a comment.

SELECT COUNT(id) AS votes_no FROM comments_votes WHERE vote = 0 AND id_comment = 1
SELECT COUNT(id) AS votes_no FROM comments_votes WHERE vote = 1 AND id_comment = 1

Ben negatif ve pozitif oy koymak için değişkenler ayarlayın: $votes_no ve $votes_yes

Sonra ben bir son var dosya: $votes_calc = $votes_yes - $votes_no;

Nasıl tek bir sorguda votes_yes, votes_no ve votes_calc sayısı alabilirim?

Thanks a lot!

0 Cevap