mysql - 如何选择包含非 ascii 字符的列名?
问题描述
我想从具有非 ascii 字符的列名中选择值,但这是不可能的。
列名是“Descripón”,我想删除“ó”并将其转换为à ³
.
如何进行选择?
解决方案
如果您使用分隔标识符,则可以使用特殊字符:
mysql> create table mytable ( `Descripón` text );
Query OK, 0 rows affected (0.03 sec)
mysql> insert into mytable (`Descripón`) values ('hello world');
Query OK, 1 row affected (0.01 sec)
mysql> select `Descripón` from mytable;
+--------------+
| Descripón |
+--------------+
| hello world |
+--------------+
如果要将列名更改为仅 ASCII 字符,以便以后可以使用它而不用分隔它:
mysql> alter table mytable change column `Descripón` Description text;
Query OK, 0 rows affected (0.02 sec)
Records: 0 Duplicates: 0 Warnings: 0
mysql> select Description from mytable;
+-------------+
| Description |
+-------------+
| hello world |
+-------------+
但是你不能像ó
在 MySQL 查询中那样使用 HTML 实体,抱歉。
推荐阅读
- spring-boot - 尝试在 Java Spring Boot 中从 H2 数据库中获取相关实体
- ansible - 单个项目和项目列表的循环和 with_items 行为之间的区别
- html - 将css文件链接到html文件时的根目录
- python - OpenCV - 从二维图像点正确恢复姿势和地标位置
- r - 反转变量列表的值
- python - 尝试绘制一个对象:使用 matplotlib 在数据集中列出日期列
- data-science - 使用 Geopandas 返回多边形上的数据点
- c++ - Codecademy - 向量:操作
- google-apps-script - eventOpenTrigger - 谷歌应用脚本只触发的第一次
- python - 在第二次输入“否”后,循环不会结束