folks. I'm new at MySQL programming and I've tried all things to manage this.
I would like to do a insensitive search with/without accents, lowercases or uppercases and all return the same results.
SELECT * FROM table WHERE campo_pesquisado LIKE '%termo_pesquisado%' ORDER BY campo_pesquisado ASC
So, in my DB (MyISAM - collation utf8_general_ci) I have this
+---------+--------+
| campo_pesquisado |
+---------+--------+
| São Paulo |
| SÃO JOÃO |
I would like to type termo_pesquisado (keywords) = São Paulo, Sao Paulo, SÃO PAULO or any combination of 'São Paulo' to get the return of São Paulo (that in browser shows correctly - São Paulo) from the database.
THE PROBLEM
If I type "são paulo, SãO PAULO or any combination with the "ã" lowercase works. It's because the UTF-8 respective code for ã is ã. If I search for SÃO PAULO, the à letter become à the full word will be SÃO PAULO that is clearly not equal to São Paulo.
TRYING
To solve this I tried this code bellow, but is not working for me.
SELECT *, CONVERT(CAST( campo_pesquisado AS BINARY) USING utf8) FROM table WHERE CONVERT(CAST( campo_pesquisado AS BINARY) USING utf8) LIKE '%termo_pesquisado%' ORDER BY campo_pesquisado ASC
IMPORTANT
I can't change my collation. We have to use utf8 as char encode for the tables. Its better for multilanguage purposes.
I'm using PHP (5.5) and the last version of MySQL.