0

In my sql table i have a column where i have values like :

enter image description here

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?

hitesh.gawhade
  • 337
  • 3
  • 6
  • 21

3 Answers3

4

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 ;-)

kmkaplan
  • 18,655
  • 4
  • 51
  • 65
0

You can also do:

select * from table 1 where desc like '%'%'
j__carlson
  • 1,346
  • 3
  • 12
  • 20
  • As it’s currently written, your answer is unclear. Please [edit] to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Nov 18 '21 at 07:00
0

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 "%'%";