Convert output of MySQL query to utf8(将 MySQL 查询的输出转换为 utf8)
问题描述
我的数据库中有一个表,我想运行一个类似的查询
I have a table in my database and I want run a query like
SELECT column1, column2 FROM my_table WHERE my_condition;
但我希望mysql以utf8编码返回column2
.mysql 中是否有任何功能可以执行此类任务?那是什么?
but I want the mysql to return the column2
in utf8 encoding. Is it any function in mysql to do such task? What is that?
推荐答案
您可以使用 CAST 和 CONVERT 在不同类型的编码之间切换.请参阅:http://dev.mysql.com/doc/refman/5.0/en/charset-convert.html
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;
这篇关于将 MySQL 查询的输出转换为 utf8的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:将 MySQL 查询的输出转换为 utf8


基础教程推荐
- Sql Server 字符串到日期的转换 2021-01-01
- 在 VB.NET 中更新 SQL Server DateTime 列 2021-01-01
- 将数据从 MS SQL 迁移到 PostgreSQL? 2022-01-01
- SQL Server:只有 GROUP BY 中的最后一个条目 2021-01-01
- SQL Server 中单行 MERGE/upsert 的语法 2021-01-01
- SQL Server 2016更改对象所有者 2022-01-01
- 无法在 ubuntu 中启动 mysql 服务器 2021-01-01
- 如何在 SQL Server 的嵌套过程中处理事务? 2021-01-01
- 使用pyodbc“不安全"的Python多处理和数据库访问? 2022-01-01
- ERROR 2006 (HY000): MySQL 服务器已经消失 2021-01-01