I have data stored in MySQL that looks like this:
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:
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 :
This SQL Fiddle demonstration shows that it does work.
Select * as Total,(select count(q1) from results where q1 = 'People\\\\\\'s') from results
it should work for u
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.