alapimba Posted August 29, 2014 Share Posted August 29, 2014 Hello I have a mysql table like this: id | user | car1 | 1 | fiat 5002 | 2 | vw polo3 | 2 | vw golf4 | 3 | renault clio5 | 2 | fiat panda 6 | 3 | seat ibizaFrom this table how can i get a query that the result be like: user 2 - 3 cars user 3 - 2 cars user 1 - 1 cars Thanks Link to comment https://forums.phpfreaks.com/topic/290732-how-to-create-ranking-and-order-mysql-table/ Share on other sites More sharing options...
Psycho Posted August 29, 2014 Share Posted August 29, 2014 SELECT user, COUNT(car) as car_count FROM table_name GROUP BY user ORDER BY car_count Link to comment https://forums.phpfreaks.com/topic/290732-how-to-create-ranking-and-order-mysql-table/#findComment-1489295 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.