Search code examples
mysqlselectsqlyognon-english

MySQL: Non-english characters messes up our SELECT queries


Have a problem doing select queries on our MySql database.

This query is working fine:

SELECT name FROM products WHERE brand = 'nike'

This one doesn't:

SELECT name FROM products WHERE brand = 'tøj'

There are 1,000+ products with brand = 'tøj', so I guess the problem is related to the non-english character.

Strange thing is that it's only when running the query via Wordpress/PHP that things doesn't work. If I run SELECT name FROM products WHERE brand = 'tøj' through SQLYog, I get the results that I expect.

Does anyone know how to fix this?

Thanks!


Solution

  • Fixed it by converting the "ø" to "ø" (based on http://www.i18nqa.com/debug/utf8-debug.html)

    i.e. SELECT name FROM products WHERE brand = 'tøj' instead of SELECT name FROM products WHERE brand = 'tøj'