我将数据存储在MySQL中,如下所示:
q1
People\'s
People\'s
People\'s
我正在尝试编写MySQL语句以返回这些计数,但这导致了我的问题,我尝试了以下所有方法,但无济于事:
SELECT * AS Total,
(SELECT COUNT(q1) FROM results WHERE q1 = 'People\'s') AS Count_Q1
FROM results
SELECT * AS Total,
(SELECT COUNT(q1) FROM results WHERE q1 = 'People'\'s')
FROM results
SELECT * AS Total,
(SELECT COUNT(q1) FROM results WHERE q1 = 'People''\'s')
FROM results
谁能发现我要去哪里错了?
最佳答案
它应该是:
SELECT *,
(SELECT COUNT(q1) FROM results WHERE q1 = 'People\\\'s') AS Total
FROM results
上面的内容来自MySQL Documentation:
此SQL Fiddle演示表明它确实有效。
关于php - 在MySQL语句中返回\',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25731777/