I have two tables - an article table and a voting table. Users can vote or vote for articles of their choice (similar to Reddit). Fields that I have in the voting table:
The value of the voting field can be 0 or 1 ... (0 if they voted for the article, 1 if they vote).
I am trying to execute a SELECT query that returns all articles with the highest score. That is, upvotes minus downvotes. However, I completely lost how this will be done. I can return all the articles that have the most revolutions, for example:
SELECT article.title, article.summary, COUNT( user_article_vote.vote ) AS votes
FROM article
INNER JOIN user_article_vote ON article.article_id = user_article_vote.article_id
WHERE user_article_vote.vote = '1'
ORDER BY votes
, (upvotes - downvotes)?
.