简体   繁体   中英

mysql query select like with diacritic Turkish letters

I have a token table in Turkish ; it's default collation is utf8_general_ci On FreeBSD server, mysql version is 5.6.15

I want to query;

select * from tokens where type like 'âmâ';

or

select * from tokens where type='âmâ';

With these queries, result must be one unique for 'âmâ' (it means 'blind' in Turkish also) But i have four raw result;

result 1 "amâ" means 'but'
result 2 "ama" means 'but'
result 3 "âma" means 'blind'
result 4 "âmâ" means 'blind'

that didnt i want.

I tried different collations and character sets and names. But same results with working ones.

Any help please

You could force a binary comparison:

SELECT * FROM tokens WHERE BINARY type='âmâ';

please see the documentation of the binary operator .

The Turkish collation is latin5_turkish_ci . See: Character Sets and Collations in MySQL .

Use the COLLATE keyword in the WHERE -clause.

SELECT *
FROM tokens
WHERE type = 'âmâ' COLLATE latin5_turkish_ci;

I have not tested it. I hope it helps.

See: Using COLLATE in SQL Statements and Collation of Expressions .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM