我正在實現一個帶有MySQL和Node.js的投票系統,它現在工作良好,但有1個問題。我有一個表文章與2關係upvotes和downvotes。MySQL選擇2個關係的計數
如果我去找我的所有文章,我想有upvotes和downvotes計數。第一個表是用
SELECT articles.*, count(downvotes.articles_id)
as downvotes
from articles
left join downvotes
on (articles.id = downvotes.articles_id)
where articles.communities_id = '52'
group by articles.id
ORDER BY created_at
DESC [![Sequel Pro][1]][1]
工作,我怎樣才能在查詢中添加upvotes嗎?
謝謝!
馬茨
同樣的方式你做了downvotes – VikingBlooded
2連接對於Mysql來說是相當簡單的任務。做到這一點。 – Serg