Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SQL Anywhere 11.0.1 (中文) » SQL Anywhere 服务器 - SQL 的用法 » 查询和修改数据 » 查询数据 » WHERE 子句:指定行

 

字符串和引号

当输入或搜索字符和日期数据时,您必须将其括在单引号中,如以下示例所示。

SELECT GivenName, Surname
   FROM Contacts
   WHERE GivenName = 'John';

如果 quoted_identifier 数据库选项设置为 Off(缺省设置为 On),则您还可以使用双引号将字符或日期数据括起来。

♦  为当前用户 ID 将 quoted_identifier 选项设置为 OFF:

提供 quoted_identifier 选项是为了与 Adaptive Server Enterprise 兼容。缺省情况下,Adaptive Server Enterprise 选项 quoted_identifier 设为 Off,而 SQL Anywhere 选项 quoted_identifier 设为 On。请参见quoted_identifier 选项 [兼容性]

字符串中的引号

在字符条目中指定文字引号有两种方法。第一种方法是使用两个连续的引号。例如,如果您以一个单引号开始字符条目并想包括一个单引号作为条目的一部分,则请使用两个单引号:

'I don''t understand.'

对于双引号(quoted_identifier 设置为 Off),指定:

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

第二种方法只有在 quoted_identifier 设置为 Off 时才适用,该方法是将一种引号括在另一种引号中。换句话说,将包含双引号的条目括在单引号中,反之亦然。以下是一些示例:

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