Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Using an apostrophe in LIKE statement

Posted on 2008-10-01
2
Medium Priority
?
1,306 Views
Last Modified: 2013-12-18
Using Oracle 10g.  Is it possible to use an apostrophe in a like statement?  
Example
Select * from test where col like '%apostrophe_here%'
If tried:
col like '%\'%' escape = '\'
col like '%'''%'   (3 single quotes)
col like '%''''%'   (4 single quotes)
col like '%||chr(39)||%'  
None of these worked.  Any ideas?
0
Comment
Question by:edwardui
2 Comments
 
LVL 143

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 2000 total points
ID: 22618386
try:
Select * from test where col like '%''%'

Open in new window

0
 

Author Comment

by:edwardui
ID: 22618468
That's the trick.  Thank you.  I had tried two single quotes before but had never removed the escape = '\' clause.  Looked like Select * from test where col like '%''%' escape = '\'
So with out the escape clause your response worked.  Didn't think the escape would cause an error if there were no \ in the like.
Thank you
0

Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Confronted with some SQL you don't know can be a daunting task. It can be even more daunting if that SQL carries some of the old secret codes used in the Ye Olde query syntax, such as: (+)     as used in Oracle;     *=     =*    as used in Sybase …
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
This video shows how to Export data from an Oracle database using the Datapump Export Utility.  The corresponding Datapump Import utility is also discussed and demonstrated.
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question