A way that might satisfy everybody is to use GROUP BY() and drop
DISTINCT.  That's a more robust method anyway.

So, for a distinct, instead of:

SELECT DISTINCT name, (SUBSTRING(name, 1, 3)) AS short_name FROM thing
WHERE is_ok = 1 /* Which produces the incorrect values stated above */

Use:

SELECT (SUBSTRING(name, 1, 3)) AS short_name FROM thing WHERE is_ok =
1 GROUP BY short_name

I think this solution is much more powerful programmatically as it can
be extended more easily (i.e. for multi-column uniqueness, aggregate
methods).


On Wed, Nov 19, 2008 at 7:23 PM, Steve Holden <[EMAIL PROTECTED]> wrote:
>
> Malcolm Tredinnick wrote:
> [...]
> > Hopefully, MySQL will fix their bug one day. That's the way to resolve
> > this.
> >
> Just so long as nobody holds their breath waiting ...
>
> regards
>  Steve
> --
> Steve Holden        +1 571 484 6266   +1 800 494 3119
> Holden Web LLC              http://www.holdenweb.com/
>
> >

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-developers@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to