個人資料
最新文章
文章分類
歸檔
正文

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...
登錄後才可評論.