Jump to content

MySQL query help -> GROUP BY and ORDER BY


Wuhtzu

Recommended Posts

Hey guys

I have this pretty ugly MySQL query:

[code]SELECT name,id,date,string_length,firstmatch_key,firstmatch_string,secondmatch_key,secondmatch_string,MIN(diff)
FROM gorandom_log
WHERE string_length=".$string_length."
GROUP BY name
ORDER BY diff ASC
LIMIT 10[/code]

The purpose of the query is to select the smallest "diff" for each "name" and them sort them by the diff ascading. My problem is that does not order them by diff...

What is wrong with my query and how to correct it?

Best regards
Wuhtzu
Link to comment
https://forums.phpfreaks.com/topic/29423-mysql-query-help-group-by-and-order-by/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.