Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find double quotes in MySQL column

Tags:

mysql

I want to find data with double quotes. I have the next simple query:

SELECT * FROM table_name WHERE column_name LIKE "%\"%";

But I have syntax error:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '"%\"%' at line 1

What should I do to find this data with double quotes(")?

like image 777
Alex Pliutau Avatar asked Dec 03 '22 00:12

Alex Pliutau


2 Answers

Because the \ character is used by the LIKE operator itself you have to double it when you use it to escape another character like the double quote.

see here

SELECT * FROM table_name WHERE column_name LIKE "%\\"%";

should work for you.

as will changing out the double quotes for single quotes to enclose the literal

SELECT * FROM table_name WHERE column_name LIKE '%"%';

as you posted here

like image 63
TetonSig Avatar answered Dec 04 '22 12:12

TetonSig


try

SELECT * FROM table_name WHERE column_name LIKE '%"%';
like image 45
diEcho Avatar answered Dec 04 '22 14:12

diEcho