Basically I am trying to join 2 tables and then return the result, below is the code I use. The problem is, lets say I want to grab the row only from 'Tina' to 'Ben'. It will not be possible since it has no ids, if I somehow include their ids, it will be in random numbers and not in orders. Is there anyway to handle this type of issue?
SELECT names.name, COUNT(item) AS items
FROM names
LEFT JOIN names_items
ON names.name = names_items.name
GROUP BY names.name
ORDER BY COUNT(item) DESC
The result would be something like this.
| Names | Items |
Bob 60
Tina 32
Arthur 43
Ben 21
Ronie 54