... WHERE 字段=值;
... WHERE 字段 LIKE '值'; -- 值可以使用通配符 %、* 等
SELECT * FROM Student;
-- 查询以 na 开头
SELECT * FROM Student WHERE name LIKE 'na%';
-- 查询以 3 结尾
SELECT * FROM Student WHERE name LIKE '%3';
-- 查询包含 z
SELECT * FROM Student WHERE name LIKE '%z%';
image.png
... WHERE 字段名 [NOT] BETWEEN 开始 AND 结束;
SELECT * FROM Student;
-- 查询 ID 为 9~11 的数据
SELECT * FROM Student WHERE ID BETWEEN 9 AND 11;
-- 查询 ID 不为 9~11 的数据
SELECT * FROM Student WHERE ID NOT BETWEEN 9 AND 11;
-- BETWEEN ... AND ... 不止可以用于数字,字符串、日期等字段类型也可以
SELECT * FROM Student WHERE name BETWEEN 'a' AND 'n';
image.png
image.png
网友评论