Order MySQL result by occurence of a field

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

Download this snippet

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

Twitter Twitter

0 Comments to “ Order MySQL result by occurence of a field”

Leave a Comment

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>