Contents Index Matching character strings in the WHERE clause Unknown Values: NULL

ASA SQL User's Guide
  Queries: Selecting Data from a Table
    The WHERE clause: specifying rows

Character strings and quotation marks


When you enter or search for character and date data, you must enclose it in single quotes, as in the following example.

SELECT first_name, last_name
FROM contact
WHERE first_name = 'John'

If the quoted_identifier database option is set to OFF (it is ON by default), you can also use double quotes around character or date data.

Interactive SQL automatically sets quoted_identifier to ON for the duration of the Interactive SQL session.

To set the quoted_identifier option off for the current user ID

The quoted_identifier option is provided for compatibility with Adaptive Server Enterprise. By default, the Adaptive Server Enterprise option is quoted_identifier OFF and the Adaptive Server Anywhere option is quoted_identifier ON.

Quotation marks in strings 

There are two ways to specify literal quotations within a character entry. The first method is to use two consecutive quotation marks. For example, if you have begun a character entry with a single quotation mark and want to include a single quotation mark as part of the entry, use two single quotation marks:

'I don''t understand.'

With double quotation marks (quoted_identifier OFF):

"He said, ""It is not really confusing."""

The second method, applicable only with quoted_identifier OFF, is to enclose a quotation in the other kind of quotation mark. In other words, surround an entry containing double quotation marks with single quotation marks, or vice versa. Here are some examples:

'George said, "There must be a better way."'
"Isn't there a better way?"
'George asked, "Isn''t there a better way?"'

Contents Index Matching character strings in the WHERE clause Unknown Values: NULL