Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Ways to escape single quotes in SQL 'LIKE' command

What are the various ways to ESCAPE single quotes(') in the SQL LIKE command?

One way is to put two single quotes whenever you have to escape a single quote.

Can you people suggest something?

Databases: SQL Server 2005 and Oracle 10g

like image 634
Egalitarian Avatar asked Aug 17 '10 15:08

Egalitarian


1 Answers

You already have the answer. You have to use two single quotes:

select * from table where field like '%''something''%'
like image 90
Justin Niessner Avatar answered Nov 09 '22 01:11

Justin Niessner