I have 3 tables in MySQL
USERS
uid
email
password
created
This is the table that have all records of all users
PHOTOS
iid
uid
file
thumb
uploaded
This is the table where all photos posted by each user are kept on
COMMENTS
cid
iid
uid
message
created
This is the table where all the comments on each photo by every user are kept on
What i want is a query that retrives me the amount (COUNT) of comments on every photo for every unique (DISTINCT) user.
For example (the resulting output must be) :
comment_amount by_user on_picture
3 1 1
2 2 1
2 1 2
5 2 2
6 2 3
so the output could tell us if it is formated something like (example)
3 comments posted by USER1 on PICTURE1
2 comments posted by USER2 on PICTURE1
2 comments posted by USER1 on PICTURE2
5 comments posted by USER2 on PICTURE2
6 comments posted by USER2 on PICTURE3
What i have so far is
SELECT
users.uid
FROM users
INNER
JOIN photos
ON photos.uid = users.uid
INNER
JOIN comments
ON comments.iid = photos.iid
and here is the sandbox testing
http://sqlfiddle.com/#!2/955d5/1
But I don’t know what to do next. Also any language besides MySQL should work as well!
or just
if you just need the data in the comments table