user
id | name
1 | A
2 | B
article
id | title | descritption
1 | wx | xyz
2 | yz | abc
article_rating
article_id(article->id) | given_by(user->id) | given_rating
1 2 4
2 1 3
saved_article
article_id(article->id) | saved_by(user->id)
1 2
I'm changing some buttons and icons depending on whether a user has rated/ saved an article or not. I'm using two select queries for that:
rated or not
SELECT given_rating as rating
FROM article_rating
WHERE given_by=? AND article_id=?
saved or not
SELECT saved_by as saved
FROM saved_article
WHERE saved_by=? AND article_id=?
So my question is how can i combine both into one mysql query efficiently??
SHOW CREATE TABLE tablestructures also for every table..