NYCPHP Meetup

NYPHP.org

[nycphp-talk] MySQL and ORDER BY kludging

Adam Maccabee Trachtenberg adam at trachtenberg.com
Wed Mar 3 10:56:23 EST 2004


On Wed, 3 Mar 2004, Chris Bielanski wrote:

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

You want to use MySQL 4.1. See:

http://www.mysql.com/doc/en/Charset.html
http://www.mysql.com/get/Downloads/Presentations/MySQL-User-Conference-2003/National-Character-Sets-and-Unicode.pdf/from/pick

> 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:

>From what I've read, you can get MySQL 4.1 to collate a table based on
a character set. I haven't actually played with this feature, however,
so I would be interested in your experiences.

Also, if you're using MySQL 4.1 with PHP 4, be sure to use the
--old-passwords flag and don't upgrade the password on any account
that uses the old mysql client to the larger length, or you'll be
stuck. :)

If you're using PHP 5, then you should download the latest MySQL 4.1.x
snapshot from http://snaps.mysql.com as the most recent packaged
version won't work.

-adam

-- 
adam at trachtenberg.com
author of o'reilly's php cookbook
avoid the holiday rush, buy your copy today!



More information about the talk mailing list