views:

47

answers:

1

I need to find occurences of é ou è in a mysql table.

First tried : SELECT "LéL" like "%é%"; which doesn't work : it returns word containing e or é or è.

I also tried with regex without results (using the the letter L):

SELECT "Lbc" REGEXP ".*L.*";  -- works : it finds L in the string LBC

SELECT "Lbc" REGEXP ".*\u4C.*"; -- doesn't work : can't find the hexadecimal equivalent of L in the string LBC.

I wanted to test the \u plus hexadecimal search... I also tried double escaping as mentionned in the doc without changes.

Regex searching seems to be really limited in mysql. Didn't find any doc related to \u on http://dev.mysql.com/doc/refman/4.1/en/regexp.html.

I'm using mysql 4.1.

If there is a solution in mysql 5 which doesn't exist in 4, I would like to know about it.

+1  A: 
SELECT 'LéL' LIKE '%é%' COLLATE utf8_bin;
/* latin1_bin if your data is in latin1, etc. */
1

SELECT 'LéL' LIKE '%e%' COLLATE utf8_bin;
0

see http://dev.mysql.com/doc/refman/5.0/en/string-comparison-functions.html#operator%5Flike and http://dev.mysql.com/doc/refman/5.0/en/charset-binary-collations.html

tested in MySQL 5.1 - should work in 4.1, too.

ax
+1 for good answer but Longneck has has simpler solution. (waiting for him to post his comment as an answer)
Silence
.... too bad. I accept your solution.
Silence