@vincebowdren answer above works, I just add this as an answer for formatting:
CREATE TABLE `members` ( `id` int(11) DEFAULT NULL, `lastname` varchar(20) COLLATE utf8_unicode_ci DEFAULT NULL ); insert into members values (1, 'test6ë'); select id from members where lastname like 'test6e%';
Productivity
+ ------ +
| id |
+ ------ +
| 1 |
+ ------ +
And using Latin1,
set names latin1; CREATE TABLE `members2` ( `id` int(11) DEFAULT NULL, `lastname` varchar(20) CHARACTER SET latin1 DEFAULT NULL ); insert into members2 values (1, 'Renée'); select id from members2 where lastname like '%Renee%';
will give:
+ ------ +
| id |
+ ------ +
| 1 |
+ ------ +
Of course, the OP must have the same encoding in the application (PHP), the connection (MySQL on Linux is used by default for latin1 in 5.0, but the default is UTF8 in version 5.1), and the data type in the field has fewer unknowns. Collages take care about everything else.
EDIT: I wrote should to better control everything, but it also works:
set names latin1; select id from members where lastname like 'test6ë%';
Because once the charset is installed, MySQL does an internal conversion. In this case, it somehow converts and compares the UTF8 string (from the database) with latin1 (from the request).
EDIT 2: Some skeptics require me to provide an even more convincing example:
Given the above statements, here's what I've done more. Make sure the terminal is in UTF8.
set names utf8; insert into members values (5, 'Renée'), (6, 'Renêe'), (7, 'Renèe'); select members.id, members.lastname, members2.id, members2.lastname from members inner join members2 using (lastname);
Remember that members is in utf8 and members2 is in latin1.
+ ------ + ---------- + ------ + ---------- +
| id | lastname | id | lastname |
+ ------ + ---------- + ------ + ---------- +
| 5 | Renée | 1 | Renée |
| 6 | Renêe | 1 | Renée |
| 7 | Renèe | 1 | Renée |
+ ------ + ---------- + ------ + ---------- +
which proves with the right settings, sorting does the job for you.