I am trying to display items from a table and order them by number of likes. The likes are in another table, and that makes me confused. The first table images looks like this:
images
id url
1 blablabla.jpg
2 hejhej.png
3 picture.jpg
And the second one, likes, looks like this:
likes
id image
1 2
2 2
3 1
4 3
5 2
Now I want the images to be ordered by most likes. What do I write in the query to make it look like this?:
hejhej.png - 3 likes
blablabla.jpg - 1 like
picture.jpg - 1 like
I would really appreciate if you could help me with my problem.
To get records from the last 24 hours only, add this to your query: