一.条件查询 where
1.等值查询 =
select * from student where id=1;
2.不等值查询 != (< >)
查询年龄不是20岁的学生信息
select * from student where age!=20;
3.关系比较查询 < <= > >=
查询年龄大于20岁的学生信息
select * from student where age>20;
4.逻辑运算查询 and or
and 满足所有条件 or只需要满足其中一个条件
查询年龄小于21岁并且住址是郑州
select * from student where age<21 and address="郑州";
查询年龄小于21岁或者住址是郑州的
select * from student where age<21 or address="郑州";
5.区间查询 between .. and (包含边界值)
查询年龄是18岁到21岁之间
select * from student where age between 18 and 21;
select * from student where age>=18 and age<=21;
6.模糊查询 like
① %(匹配0-n个字符)
查询学生表中名字包含x的学生信息
select * from student where stuname like
Mysql笔记篇(Mysql数据库的几个查询)
这篇博客详细介绍了MySQL数据库的查询操作,包括条件查询(等值、不等值、关系比较、逻辑运算、区间、模糊)、排序查询(order by、limit)、聚合函数(sum、avg、max、min、count)、分组语句(group by、having)以及别名的使用。通过实例解析了各种查询方法的应用,帮助读者深入理解MySQL查询语句。
摘要由CSDN通过智能技术生成