如何使用MySQL检查where子句的撇号 [英] How to check Apostrophe with where clause using mysql
本文介绍了如何使用MySQL检查where子句的撇号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
在MySQL的WHERE
子句中如何使用撇号(')?
How is an apostrophe (') used with the WHERE
clause in MySQL?
我已经使用mysql_real_escape_string
清理了输入.
I have used mysql_real_escape_string
to sanitise input already.
这是我的mySQL查询和数据库的屏幕截图
Here is a screenshot of my mySQL query and database
SELECT * FROM players WHERE `name` = 'Amar'e Stoudemire'
执行此查询会产生以下错误:
Executing this query generates the following error:
知道为什么吗?
推荐答案
SELECT * FROM players WHERE `name` = 'Amar\\''e Stoudemire'
如果单元格内容为\'
,则必须转义两个字符:
If your cell content is \'
then you have to escape both characters:
\
-> \\
'
-> ''
\
--> \\
'
--> ''
这篇关于如何使用MySQL检查where子句的撇号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文