[DB-SIG] Strange resultset with ORDER BY col1, GROUP BY col2
kolbe at kolbekegel.com
Fri Jun 24 17:28:11 CEST 2005
> As group_concat is a MySQL specific function I suspect that the
> problem you are seeing is specific to the MySQLdb module.
This seems reasonable. I suppose that I ought to make an attempt to
contact the maintainer directly. I'll look into doing so soon.
> I'm running MySQL 4.0.17 and your query doesn't work as GROUP_CONCAT
> is not available in this version.
Upgrade! You're missing out on a lot of great features in 4.1 :)
> A couple of questions do spring to mind though;
> - Do you really need to group by one thing and order by another?
Absolutely. In my application, I want a lit of actions grouped by the
type of action and upon whom it was performed and ordered by the most
recently performed action in each of those groups.
> - Do you need to do the group_concat transposition in SQL or would it
> be better achieved in Python after you've select all of the group,
> comment pairs from the database?
Of course there are workarounds. Unfortunately, as Chris pointed out,
the workarounds will result in unnecessary inefficiency. At any rate,
this is almost certainly a bug in MySQLdb, so fixing that is preferable
to developing workarounds. At this point, my workaround is to simply
use .tostring() in my application, but that's a rather ugly and short
Thanks for your comments.
More information about the DB-SIG