NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL and ORDER BY kludging

Chris Bielanski Cbielanski at inta.org
Wed Mar 3 10:49:38 EST 2004


Hey list,
Does anyone have experience with making MySQL do an ORDER BY for different
(or multiple) charsets?

I have DB full of unicode (single-byte, I think) strings and the default
ORDER BY is UTF-8 according the MySQL docs. They also mention that this can
be altered but I couldn't quite figure out how to go about it.

Predictably, there is an interest in getting the sort from the query such
that:

$query = 'Select distinct from MYDB where strings >="S" and strings < "T"';
would capture "S-like" strings starting with  [S,s,S,s,S,s,S,s,S,s], which
when UTF-8 sorted, the set [S,s,S,s,S,s,S,s] falls last, or > "Z"

and for another example, 'Select distinct from MYDB where strings >="C" and
strings < "D"'; would bring back strings starting with
[C,c,ç,C,c,C,c,C,c,C,c].

Any insights?

Thanks,
Chris Bielanski - [CBielanski at inta.org]
Web Programmer, 
International Trademark Association - [www.inta.org]
1133 Ave. of the Americas - Manhattan
p - 212/642-1745







More information about the talk mailing list