Reputation: 347
In my sql table i have a column where i have values like :
I need to find these type of entries and remove single quotes as i dont need them, but how to fetch them through query in where clause ? If i use select * from table 1 where desc = 'the values is '10', it simply wont work as the statement is not correct. how can i modify my where clause to get desired result?
Upvotes: 0
Views: 9989
Reputation: 1
try to use different quote types (double and single) inside and outside value. for example
SELECT * FROM table 1 WHERE desc = "the values is '10'";
or find all rows at once which contain single quote in desc
SELECT * FROM table 1 WHERE desc LIKE "%'%";
Upvotes: 0
Reputation: 18960
Double the quotation mark to escape it :
select * from table 1 where desc = 'i am ''not'' a graduate'
As a side note, don’t select *
, explicitly list the columns you are interested in:
select id, "desc" from table 1 where desc = 'i am ''not'' a graduate'
… And don’t name your columns with SQL reserved words ;-)
Upvotes: 4