1

I have a MySQL table that contains texts (nicknames) with Turkish characters in them. For example, there is a word "çığır" in Turkish. ( "cigir" with english characters ) It is stored in the database like "çığır". When I print this word in my .php page, it is printed correctly (as "çığır").

But when I do the query

SELECT * FROM  users WHERE nickname LIKE 'çığır';

it returns an empty set. of course the other way (nickname like çığır) works, but I want do be able to do the first one, too. How can I do this?

p.s.: I have tried

SET NAMES 'UTF8';
SET character_set_connection = 'UTF8';
SET character_set_client = 'UTF8';
SET character_set_results = 'UTF8';

these don't work.

Thanks in advance!

marvin
  • 1,847
  • 4
  • 15
  • 20
  • try SELECT * FROM users WHERE nickname LIKE '%çığır%'; that way it will find the word anywhere in the string. – justMe Jan 16 '13 at 11:00
  • Where do you do the query from? What collation is the table in? – Pekka Jan 16 '13 at 11:02
  • I tried the query in both PHPmyAdmin and .php scripts none worked. Collation is utf8_turkish_ci. thanks for all answers. I will try them now. – marvin Jan 16 '13 at 12:04

2 Answers2

2

Try this:

SELECT * FROM  users WHERE Convert(nickname using utf8) LIKE 'çığır';
LuigiEdlCarno
  • 2,410
  • 2
  • 21
  • 37
0

You might be better off translating the database to UTF-8, making sure php is querying with the right charset,

$link = mysql_connect('localhost', 'user', 'pass');
mysql_set_charset("UTF8", $link);

and forget about the funny encoding altogether. This way all your queries will work automatically.

Riccardo Zorn
  • 5,590
  • 1
  • 20
  • 36