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
you can create a column while creating all those table make the column name id and the properties of id will be
-> id INT NOT NULL AUTO_INCREMENT PRIMARY KEY,
then you can use this id to select what u want
You might try adding "WHERE names.name in ('Tina', 'Ben', 'Arthur')?
This is based on you wanting Tina, Ben, and Arthur's information.
Or LIMIT (2,x) (Where x is the distance between Tina and Ben)
This only works if Tina is ALWAYS the second record, and Ben is ALWAYS the same distance from Tina AND always comes after Tina.
A more complicated way to do it would be to:
I don't think there is a "good" solution to this question, and it would be easier to answer if we knew WHY you were wanting everyone between Ben and Tina...is there something special about Ben and Tina?