1

I am getting wrong output if i use Unicode tamil characters in LIKE MySQL query

Select * from tbl_name where colName LIKE 'ச%';

In the above Query I am getting records starting with சொ,சு,சே,சூ,சா,சி. what I need is the letter starting only.

colHWord சகதி சக்தி சகாயம் சகுனம் சங்கம் சங்கிரகம் சங்கு சடை சத்தியம் சந்தடி சந்தர்ப்பம் சந்திரகலை சந்தேகம் சபதம் சப்பு சபை சம்பிரமம் சம்புடம் சமம் சம்மதம் சமயம் சமன் சரி சரிவு சலனன் சறுக்கு சனி சாக்கு சாட்சி சாணம் சாத்து சாதனம் சாதனை சாதி சாந்து சாபம் சாமர்த்தியம் சாய் சாய்வு சாயை சார் சார்பு சாவகாசம் சாறு சிக்கனம் சிகரம் சிங்காரம் சித்திரம் சித்திரி சிதறு சிதைவு சிந்து சிலை சிவப்பு சிறகு சிறப்பு சிறப்புவிதி சிற்றுண்டி சிறை சின்னம் சினேகம் சினை சீவு சுடு சுமை சுரண்டு சுரணை சுருக்கம் சுருக்கு சுருங்கு சுருட்டு சுவர் சுவை சுழி சுற்றம் சுற்று சூரியன் சூழ்ச்சி சூழ்வோர் செதுக்கு செம்மறி செய்தி செருக்கு செருகு செல்வம் செலவு செழிப்பு செறிவு சேர் சேவகம் சேவை சேறு சேனை சொரி சொல் சோபானம் சோம்பு சோறு சௌக்கியம்

6
  • 1
    what is the character set in mysql Table and column ? Commented Aug 21, 2015 at 6:40
  • Please show us the mysql create table stmt and the values. Commented Aug 21, 2015 at 6:55
  • CREATE TABLE tbl_tamilvt ( colID int(11) NOT NULL AUTO_INCREMENT, colHword text, colJword longtext, PRIMARY KEY (colID) ) ENGINE=InnoDB AUTO_INCREMENT=1102 DEFAULT CHARSET=utf8; Commented Aug 21, 2015 at 6:56
  • Could it be a collation problem? Can you give us the result of show table status like 'tbl_name'? (it's better to add it in your answer directly - easier to read) Commented Aug 21, 2015 at 7:24
  • @mcbalaji change mysql charater set : utf8,and Collation : utf8_general_ci for your column and table to :D Commented Aug 21, 2015 at 8:21

3 Answers 3

1

You can use LIKE BINARY in place of %, something like this

Select * from tbl_name where colName LIKE BINARY 'ச';
Sign up to request clarification or add additional context in comments.

Comments

0

Normaly LIKE should work with 'ச%'.

But you can try to use the unicode as hex value OR you could also use the REGEXP operator.

Adjust your SQL statement like this

SELECT * FROM tbl_name WHERE colName  REGEXP '^ச.*';

1 Comment

The result is same when i use REGEXP
0

சொ,சு,சே,சூ,சா,சி are the combination of two Unicode character so query must be specific to pull ச. Below is the one of the way to omit other letters

SELECT * FROM tbl_name WHERE colName LIKE 'ச%' AND colName NOT LIKE 'சா%' AND colName NOT LIKE 'சி%' AND colName NOT LIKE 'சு%' AND colName NOT LIKE 'சொ%' AND colName NOT LIKE 'சே%' AND colName NOT LIKE 'சூ%';

There should some other way using REGEXP, But I'm unable to find it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.