Apostrophe replacement in mysql query

I have column names (notes) as

Notes:

John's table

Smith Window 

The column contains an apostrophe. I am trying to run 2 queries.

  • Select a query to get the column entries with an apostrophe.
  • Update those with an apostrophe with an empty string, i.e. Replace John's table with John's table

select notes from table 1, where notes are of type "%";

I get a syntax error, any help would be great.

+4
source share
2 answers

Apostrophe escape with a backslash;

 select notes from table1 where notes like '%\'%'; 

And to update, use REPLACE ()

 UPDATE table1 SET notes = REPLACE(notes, '\'', ''); 
+5
source

Have you tried:

 select notes from table1 where notes like "'%"; 
0
source

All Articles