Question & Answer
Question
How do I identify rows in which the value contains a single quote (') character such as in the name O'Leary?
Answer
To create an SQL query that identifies all rows which have a single quote in its value, you must escape the single quote by using two single quotes.
Examples
To find all rows in a table which have a column named col1 and the value of col1 contains a single quote, use the following SQL:
SELECT * from <table> where col1 like '%''%';
To find all rows in a table which have a column named col1 and the value of col1 = O'Leary, use the following SQL:
SELECT * from <table> where col1='O''Leary';
Historical Number
NZ045232
Was this topic helpful?
Document Information
More support for:
IBM PureData System
Software version:
1.0.0
Document number:
461335
Modified date:
17 October 2019
UID
swg21568936