im trying to get a list from the database, and group those that have the same name, but anytime i try to add
GROUP BY title
it just returns 1 result,
not really sure why its not working, ive done it a bunch of times before. i must be missing something
any suggestions
If you’re not counting the results, then just use a SELECT DISTINCT instead of grouping the results.
So your example would be SELECT DISTINCT vehicle FROM tableName
ORDER BY sorts the set(s). GROUP BY returns multiple sets (If GROUP BY is left out, the results are returned as a single set)
My first impulse is to say your first code snippet was grouping by title, but your table of data has the header listed as vehicle… so Grouping by the right fieldname is a start.
well doesnt order by just order them by a number… for example
ID VEHICLE
1 car
2 airplane
3 train
4 car
5 motorcycle
6 airplane
7 car
so what im trying to do is group the ones with the same name, so GROUP BY should give me this
car
airplane
train
motorcycle
but its only giving me one result
wouldnt order by, just order the results by alphabet, but still show 7 results instead of just 4?
r937
June 7, 2010, 11:32pm
5
i think what you’re missing is the difference between GROUP BY and ORDER BY