Rick
Rick

Reputation: 373

How to write select query if the condition contains single quotes(')

I Want to retrive the data from Oracle DB where name contins single quote(')

Select * from table_name where name in ('Joel D'Silva','O'neil Dsa');

Upvotes: 1

Views: 4959

Answers (2)

You could pass string to q'[]' in following:

Select * from table_name where name in (q'[Joel D'Silva','O'neil Dsa]');

or you could use quote ' twice in following:

Select * from table_name where name in ('Joel D''Silva'',''O''neil Dsa');

Upvotes: 4

Felix Pamittan
Felix Pamittan

Reputation: 31879

Replace ' with '':

Select * from table_name where name in ('Joel D''Silva','O''neil Dsa');

Upvotes: 3

Related Questions