TOP子句 - 用于规定要返回的记录的数目。并不是所有数据库都支持TOP子句。
语法:
SQLServer:SELECT TOP number|percent columnName(s) FROM tableName
MySQL:SELECT columnName(s) FROM tableName LIMIT number
Oracle:SELECT columnName(s) FROM tableName WHERE ROWNUM <= number
TOP示例:
1.SELECT TOP 2 * FROM tableName -- 查询表中前两行记录
2.SELECT TOP 50 PERCENT * FROM tableName -- 查询表中50%的记录
IN操作符
语法:SELECT columnName(s) FROM tableName WHERE columnName IN (value1,value2,...,valuen)
BETWEEN操作符 - BETWEEN ... AND 会选取介于两个值之间的数据范围。这些值可以是数值、文本或日期。
语法:SELECT columnName(s) FROM tableName WHERE columnName BETWEEN value1 AND value2
SELECT columnName(s) FROM tableName WHERE columnName NOT BETWEEN value1 AND value2 -- 查询不在value1和value2之间的行
IS NULL 和 IS NOT NULL - 判断列值是否未NULL
语法:WHERE col IS NULL 或者 WHERE col IS NOT NULL
NULL 用作未知的或不适用的值的占位符。