About cookies on this site Our websites require some cookies to function properly (required). In addition, other cookies may be used with your consent to analyze site usage, improve the user experience and for advertising. For more information, please review your options. By visiting our website, you agree to our processing of information as described in IBM’sprivacy statement. To provide a smooth navigation, your cookie preferences will be shared across the IBM web domains listed here.
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';
[{"Product":{"code":"SSULQD","label":"IBM PureData System"},"Business Unit":{"code":"BU053","label":"Cloud & Data Platform"},"Component":"Database","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"1.0.0","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}}]
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