emab emab - 10 months ago 60
MySQL Question

Convert output of MySQL query to utf8

I have a table in my database and I want run a query like

SELECT column1, column2 FROM my_table WHERE my_condition;

but I want the mysql to return the
in utf8 encoding. Is it any function in mysql to do such task? What is that?

Answer Source

You can use CAST and CONVERT to switch between different types of encodings. See: http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html

SELECT column1, CONVERT(column2 USING utf8)
FROM my_table 
WHERE my_condition;