0

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.

5
  • why can't you just send the actual character instead of the hex code? Commented Sep 4, 2009 at 18:41
  • Well I'll be damned... That's the first thing I tried... but now that I tried again after reading your comment... It works. Commented Sep 4, 2009 at 18:45
  • Turn that comment into an answer and let's be done with it. Commented Sep 4, 2009 at 18:46
  • Oh wait. I know why : I first tried LIKE "%é%" and that (!!!) doesn't work. It return normal e as well as é or è. But the regex version works for an unkown reason. Commented Sep 4, 2009 at 18:49
  • Was still worth to ask the question... I learned something about SQL. I learned that I don't like the "like" keyword. Commented Sep 4, 2009 at 18:55

1 Answer 1

1
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_like 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.

Sign up to request clarification or add additional context in comments.

1 Comment

+1 for good answer but Longneck has has simpler solution. (waiting for him to post his comment as an answer)

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.