Re: Sorting results ith umlauts in UTF8 tables

2005-09-05 Thread Gleb Paharenko
Hello.



Maybe this could help you somehow:

  http://bugs.mysql.com/bug.php?id=12191



Check that you are running the latest release.





Nico Grubert <[EMAIL PROTECTED]> wrote:

> Hi there,

> 

> I am running MySQL 4.1 on Linux.

> I have some problems sorting records with german umlauts.

> 

> MySQL is configured to have character set "UTF8" as default.

> I have created a table like this:

> 

> CREATE TABLE tblmembers (

>   memberid int(11) NOT NULL auto_increment,

>   lastname varchar(255) NOT NULL default '',

>   location varchar(255) default NULL,

>   PRIMARY KEY  (memberid)

> ) ENGINE=MyISAM DEFAULT CHARSET=utf8

> 

> The, I have inserted some records:

> INSERT INTO tblmembers (lastname,location) VALUES ('Ober','Germany');

> INSERT INTO tblmembers (lastname,location) VALUES ('Ohm','Germany');

> INSERT INTO tblmembers (lastname,location) VALUES ('$hlz','Germany');

> INSERT INTO tblmembers (lastname,location) VALUES ('$der','Germany');

> INSERT INTO tblmembers (lastname,location) VALUES ('Ower','Germany');

> 

> Now, I would like get all members whose lastname starts with 'O' (and 

> also with umlaut '$') sorted by lastname according to german sorting 

> rules, so my SQL query reads like this:

> 

> I tried:

> SELECT *

>   FROM tblmembers

>   WHERE lastname LIKE 'O%' OR lastname LIKE '$%'

> 

> The result reads like this:

> Ober

> Ohm

> Ower

> 

> Do I need to covert the '$%' somehow so the records starting with '$' 

> are also found?

> 

> 

> Example 1:

> SELECT *

>   FROM tblmembers

>   ORDER BY lastname

> 

> returns:

> $hlz

> $der

> Ober

> Ohm

> Ower

> 

> ..which is wrong according to german sorting rules.

> 

> 

> Example 2:

> SELECT *

>   FROM tblmembers

>   ORDER BY lastname

>   COLLATE utf8_general_ci

> 

> returns:

> $hlz

> $der

> Ober

> Ohm

> Ower

> 

> The proper sorting order according to german sorting rules is:

> Ober

> $der

> Ohm

> $hlz

> Ower

> 

> 

> Any idea how I can sort the results proper?

> 

> Nico

> 



-- 
For technical support contracts, goto https://order.mysql.com/?ref=ensita
This email is sponsored by Ensita.NET http://www.ensita.net/
   __  ___ ___   __
  /  |/  /_ __/ __/ __ \/ /Gleb Paharenko
 / /|_/ / // /\ \/ /_/ / /__   [EMAIL PROTECTED]
/_/  /_/\_, /___/\___\_\___/   MySQL AB / Ensita.NET
   <___/   www.mysql.com




-- 
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]



Sorting results ith umlauts in UTF8 tables

2005-09-03 Thread Nico Grubert

Hi there,

I am running MySQL 4.1 on Linux.
I have some problems sorting records with german umlauts.

MySQL is configured to have character set "UTF8" as default.
I have created a table like this:

CREATE TABLE tblmembers (
  memberid int(11) NOT NULL auto_increment,
  lastname varchar(255) NOT NULL default '',
  location varchar(255) default NULL,
  PRIMARY KEY  (memberid)
) ENGINE=MyISAM DEFAULT CHARSET=utf8

The, I have inserted some records:
INSERT INTO tblmembers (lastname,location) VALUES ('Ober','Germany');
INSERT INTO tblmembers (lastname,location) VALUES ('Ohm','Germany');
INSERT INTO tblmembers (lastname,location) VALUES ('Öhlz','Germany');
INSERT INTO tblmembers (lastname,location) VALUES ('Öder','Germany');
INSERT INTO tblmembers (lastname,location) VALUES ('Ower','Germany');

Now, I would like get all members whose lastname starts with 'O' (and 
also with umlaut 'Ö') sorted by lastname according to german sorting 
rules, so my SQL query reads like this:


I tried:
SELECT *
  FROM tblmembers
  WHERE lastname LIKE 'O%' OR lastname LIKE 'Ö%'

The result reads like this:
Ober
Ohm
Ower

Do I need to covert the 'Ö%' somehow so the records starting with 'Ö' 
are also found?



Example 1:
SELECT *
  FROM tblmembers
  ORDER BY lastname

returns:
Öhlz
Öder
Ober
Ohm
Ower

..which is wrong according to german sorting rules.


Example 2:
SELECT *
  FROM tblmembers
  ORDER BY lastname
  COLLATE utf8_general_ci

returns:
Öhlz
Öder
Ober
Ohm
Ower

The proper sorting order according to german sorting rules is:
Ober
Öder
Ohm
Öhlz
Ower


Any idea how I can sort the results proper?

Nico

--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]