Joining 4 tables in MySQL to retrive data.
I need the best way to join 4 tabels:
1. Users
ID NAME
1 me
2 you
3 her
2. Articles
ID USER_ID ARTICLE
1 1 etc
2 1 etc
3 2 third
3. Article_comments
ID ARTICLE_ID COMMENT
1 1 etc
2 1 etc
3 3 etc
4. Article points
ID ARTICLE_ID POINTS
1 1 100
2 1 200
3 2 50
4 2 10
I need a way to join them to retrieve:
ARTICLE | USERNAME | TOTAL COMMENTS PER ARTICLE | TOTAL POINTS PER ARTICLE
For example: For article 1: etc | me | 2 | 350
for 2 : etc | you | 0 | 60 and so one for all of them.
1 Answer