I have three tables:
- posts - contains the posts by users,
- post_reviews - contains the likes on the posts, and
- post_share - contains the post id and user id of that which is shared.
I would like to select five popular posts using these three tables. The popular posts are those that have the highest no of reviews and shares. I am finding it really hard to construct a SQL query for this.
A slight help or guidance in this matter will be highly appreciated.
UPDATE:
The table structure is as follows:
table posts{
id - PK
uid - FK
post - text
}
table post_reviews{
id - PK
pid - FK (Post Id)
uid - FK
like_unlike - ENUM
}
table post_share{
id - PK
pid - FK (Post Id)
uid - FK
}
SHOW CREATE TABLE posts\G,SHOW CREATE TABLE posts_reviews\GandSHOW CREATE TABLE posts_share\Gand post their output in the question. – RolandoMySQLDBA Oct 16 '12 at 14:46