个人资料
最新文章
文章分类
归档
正文

SQL tutorial

(2006-06-09 22:12:48) 下一个
The IN operator may be used if you knowthe exact value you want to return for at least one of the columns. To display the persons with LastName equal to "Hansen" or "Pettersen", use the following SQL:
SELECT * FROM Persons WHERE LastName IN ('Hansen', 'Pettersen')

The BETWEEN...AND operator selects a range of data between two values. To display the persons alphabetically between (including) "Hansen" and exclusive "Pettersen", use the following SQL:
SELECT * FROM Persons WHERE LastName BETWEEN 'Hansen' AND 'Pettersen'

The BETWEEN...AND operator is treated differently in different databases. Some only selects fields that are between and excluding the test values. Some selects fields that are between and including the test values. Some selects fields between the test values, including the first test value and excluding the last test value.

To display the persons outside the range used in the previous example, use the NOT operator:
SELECT * FROM Persons WHERE LastName NOT BETWEEN 'Hansen' AND 'Pettersen'
[ 打印 ]
阅读 ()评论 (1)
评论
stillthere 回复 悄悄话
hehehe...

I support you for putting some SQL stuff here...
登录后才可评论.