Mysql
 sql >> Database >  >> RDS >> Mysql

mysql order by max corrisponde al valore del campo

Prova questo:

SELECT DISTINCT(l.name) AS link 
FROM links l INNER JOIN tags t ON l.id = t.link_id 
AND l.id <> 1 GROUP BY t.link_id ORDER BY COUNT(t.link_id) DESC

DEMO SQLFIDDLE