Solved

Using an apostrophe in LIKE statement

Posted on 2008-10-01
2
1,289 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 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 500 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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Cursors in Oracle: A cursor is used to process individual rows returned by database system for a query. In oracle every SQL statement executed by the oracle server has a private area. This area contains information about the SQL statement and theā€¦
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
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.
This video shows how to recover a database from a user managed backup

863 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now