简体   繁体   English

在MySQL语句中返回\\'

[英]Return \' within a MySQL statement

I have data stored in MySQL that looks like this: 我将数据存储在MySQL中,如下所示:

q1
People\'s
People\'s
People\'s

I'm trying to write a MySQL statement to return a count of these but it's causing me an issue, I have tried all the following but to no avail: 我正在尝试编写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

Can anyone spot where I am going wrong? 谁能发现我要去哪里错了?

It should be: 它应该是:

SELECT *,
(SELECT COUNT(q1) FROM results WHERE q1 = 'People\\\'s') AS Total
FROM results

The above is coming right from the MySQL Documentation : 上面的内容来自MySQL文档

在此处输入图片说明

This SQL Fiddle demonstration shows that it does work. SQL Fiddle演示演示了它的确起作用。

Select * as Total,(select count(q1) from results where q1 = 'People\\\\\\'s') from results 选择*作为总计,(从结果中选择count(q1),其中q1 ='People \\\\\\'s')

it should work for u 它应该为你工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM