sql查询中的特殊字符 [英] special characters in sql query
问题描述
我正在从 xml 文件中读取数据.我的 xml 文件的城市名称类似于 İstanbul.我使用选择查询在我的城市表中检查 İstanbul.但是当我在 php 中回显我的 sql 查询时,它以这种格式显示查询
SELECT city_id FROM dc_cityWHERE (name = 'Ä°stanbul - Avrupa' OR FIND_IN_SET('Ä°stanbul - Avrupa',like_names))AND 文化 ID = 13
<块引用>
'find_in_set' 操作的排序规则 (utf8_general_ci,COERCIBLE) 和 (latin1_swedish_ci,IMPLICIT) 的非法混合
您应该更改表格的字符集/排序规则.当您尝试使用 UNICODE (UTF8) 字符串对其进行过滤时,您有一个以 ASCII 格式存储其数据的表.
查看本文档以了解事情.
改变表格的字符集:
ALTER TABLE dc_city CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
I am reading data from xml file. my xml file has city name like İstanbul. I check İstanbul in my city table by using select query. but when i echo my sql query in php it show the query in this formate
SELECT city_id FROM dc_city
WHERE (name = 'Ä°stanbul - Avrupa' OR FIND_IN_SET('Ä°stanbul - Avrupa',like_names))
AND cultureid = 13
Illegal mix of collations (utf8_general_ci,COERCIBLE) and (latin1_swedish_ci,IMPLICIT) for operation 'find_in_set'
You should change the charset/collation of your table. You have a table which stores its data in ASCII format when you try to filter it with UNICODE (UTF8) strings.
Have a look at this documentation to understand the matter.
To change the charset of a table :
ALTER TABLE dc_city CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;
这篇关于sql查询中的特殊字符的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!