I have two databases, articles and article-likes.
I need the query to select everything from the article
and add a row which is the sum of likes (we have -1 for dislike and +1 for like) from the table article-likes
by searching for their ID.
Articles table:
Article-Likes table:
For this instance, the article with ID Lorem-Ipsum
should have 2 likes. On the other hand, Sit-Amet
should have 1 like (1 + -1).
Best Answer
You can use a subquery to sum all likes of each article.