中英文字幕
查询表table中所有列数据
SELECT * FROM table
查询表table中name字段数据
SELECT name FROM table
查询表table中name和email字段数据
SELECT name , email FROM table
查询表table中name是小米的email字段
SELECT email FROM table WHERE name = '小米'
查询表table中年龄大于18的数据
SELECT * FROM table WHERE age > 18
查询表table中年龄小于18 或者年龄大于30且小于60的数据
SELECT * FROM table WHERE age < 18 OR (age > 30 AND age < 60)
查询表table中所有不重复的数据
SELECT DISTINCT * FROM table
查询表table中前2条数据
SELECT TOP 2 * FROM table
查询表table中前百分之20的数据
SELECT TOP 20 PERCENT * FROM table
查询表table中数据,修改列名name为n
SELECT name AS n FROM table
查询表table中name为姓王的数据
SELECT * FROM table WHERE name LIKE '王%'
查询表table中name为null的数据
SELECT * FROM table WHERE name IS NULL
查询表table中的数据并排序(ASC升序 ;DESC降序)
SELECT * FROM table ORDER BY id ASC
SELECT * FROM table ORDER BY id DESC
查询表table中日期在2000年6月1日到3000年9月日的数据
SELECT * FROM table WHERE date BETWEEN '2000-06-01' AND '3000-09-01'
查询表table中id为1、2、3、4、5的数据
SELECT * FROM table WHERE id IN (1,2,3,4,5)