So, I have a table full of cars:
Let's say that there are 4 dodge viper, there will be 4 entries in the database, they are all identical, except for carID.
carID | carname | carmodel | colour | reg -------------------------------------------------- 1 | viper | dodge | red | 123 2 | viper | dodge | red | 124 3 | viper | dodge | red | 125 4 | viper | dodge | red | 126 5 | R8 | audi | blue | 127 6 | R8 | audi | blue | 128
When a user searches for cars, I want to display only one evasion viper. However, I want to get all the information from this line and every other individual car.
So I want:
carID | carname | carmodel | colour | reg -------------------------------------------------- 1 | viper | dodge | red | 123 5 | R8 | audi | blue | 127
If I do this:
SELECT DISTINCT * FROM cars
he discards all entries.
SELECT DISTINCT carname FROM cars
Only one of them selects, but I have only the name of the car.
Is there such a thing:
SELECT * FROM cars ORDER BY DISTINCT carname
Or something similar?
Bohdi source share