I have a major problem getting this to work properly. Here is the deal.
I have 4 tables – timeline, connections, images, votes
Timeline table:
time_id
time_title
etc.
The timeline table connects with the images table via the connections table
Connections table:
time_id
image_id
So the connections hold information about the id of the “post” the timeline and about image id
Images table:
image_id
image_url
image_type
Images table contains images that could be used in the same timeline(post), so by this i can see the connection by looking at the connection table.
I also have a votes table that holds information about votes for the specific timeline post
Votes table:
vote_id
time_id
the votes table contains many rows of each time_id and the idea is to count the number of times to se wich is the most popular
So heres the question:
I need to get the 5 most voted time_titles and show them with the first image for each time_title(post) so that it look like this for example
- Image 1 that corresponds to Title 1 – that is the highest voted
- Image 2 that corresponds to Title 2 – that is the second highest voted
etc.
Each timeline row (post) can hold many images and i only want to show the first of each post.
Hope you understand my problem!
Thanks a lot!
The query will be
This will work, but might not be the most optimized one.
— EDIT
to get image_type also try