Username:   Password:  

Order MySQL result by occurence of a field

SELECT
 `row`,
 COUNT(row) AS `count`,
FROM
 `table`
GROUP BY
 `row`
ORDER BY
 `count`;
 
 

Sometimes it is necessary, to sort the rows of a MySQL select statement by the occurence of a field value.

Tags

MySQL count database select order occurences