Skip to main content
2 of 3
replaced http://stackoverflow.com/ with https://stackoverflow.com/
user avatar
user avatar

The best solution to this problem is, of course, using a complete GROUP BY expression.

But there's another solution that works around the ONLY_FULL_GROUP_BY blocking of the old MySQL extension to GROUP BY.

SELECT name, ANY_VALUE(type) type, ANY_VALUE(language) language, ANY_VALUE(code) code FROM users WHERE verified = '1' GROUP BY name ORDER BY count DESC LIMIT 0, 25 

ANY_VALUE() explicitly declares what used to be implicit in MySQL's incomplete GROUP BY operations -- that the server can choose, well, any, value to return.

O. Jones
  • 109.5k
  • 17
  • 134
  • 187