I have an image website, where users can upload images into public groups with basic functionality such as likes etc. I am currently building a statistics page for said groups and ideally need a single query that can get all of the likes from all of the images in a group.
Tables(with sample data below)
Group_images: ID | GROUP_ID | IMAGE_ID | TIMESTAMP
1 | 1 | 10 | 1346256053
Likes: ID | USER_ID | IMAGE_ID | TIMESTAMP
1 | 1 | 10 | 1346256090
Images : ID | HEADING | UPLOADER | FILENAME | EXT | TIMESTAMP
10 | Cats | 4 | 82375dss | .png| 134625400
So in theory it should do something like this,
Search for any images in group_images
where group_id
= '$id' --> gather all the images that are linked to the group --> search likes
for all likes that have been associated with the group by searching for any that have a matching image_id
from the first query.
I hope i have made this clear, if not please feel free to ask more questions and i will update the question with further details you need. Thank you.
EDIT I have added sample data below the tables, what i would like to achieve is to be able to see all the user_id's from all the likes from group id = 1.