I have a mysql table(trips) with records about cars. I wish to query the data and return one item per carId. But am unable. Below is the query example getting 50 records, which should also have 50 carId
SELECT *
FROM `trips`
WHERE ( carId = 147
OR carId = 62
OR carId = 59
OR carId = 42)
LIMIT 50
Below is an example that returns 8 records. How to return limit 8 records but one record per car. Example here
LIMIT 50is strange... – Akina Feb 05 '20 at 12:08carId. – Akina Feb 05 '20 at 12:10GROUP BY,SUM()– Eric Feb 05 '20 at 17:22id= 1 and cars ofids 59 and 42 duplicated. Surely, trip_id and car_id together should be aPRIMARY KEY? p.s. welcome to the forum! :-) – Vérace Feb 06 '20 at 06:46ROW_NUMBER()Window Function – John Eisbrener Feb 06 '20 at 15:16