去重 distinct
作用:去除select查询出来的结果中重复的数据,只显示一条。
-- 查询一下有哪些同学参加了考试,成绩 select * from result -- 查询全部的考试成绩 select `StudentNo` from result -- 查询有哪些同学参加了考试 -- 发现重复数据 select distinct 'StudentNo' from result -- 去重
select用法
select VERSION() -- 查询系统版本 select 100*2-1 as 计算结果 -- 用来计算 select @@auto_increment_increment -- 查询自增的步长 -- 学院考试成绩+1分查看 select `StudentNo`,`StudentResult`+1 as '提分后' from result
where条件子句
作用:检索数据中符合条件的值
-- 查询考试成绩在95~100之间的 select studentNo,`StudentResult` from result where StudentResult>=95 and StudentResult<=100 -- 模糊查询(区间) select studentNo,`StudentResult` from result where StudentResult between 95 and 100
模糊查询
比较运算法
运算符 | 语法 | 描述 |
---|---|---|
is null | a is null | 如果a为null,结果为真 |