DQL(数据查询语言)
语法:select 列名(多列间逗号,全部列用*) from 表名 [where 过滤条件 group by 分组查询 having 分组后的过滤 order by 排序 limit 分页];
1.简单的条件条件查询:
查询所有数据
select * from student(表名)
带条件查询
可以使用的条件:< , <= , = , > , >= , != , <> , in , between...and... , and , or ,not , is null , like 。
-- 查询编号为1004的学生的姓名和生日
select name,birthday from student where id=1004;
-- 查询年龄大于18的学生信息
select * from student where age>18;
-- 查询小明的成绩
select name,score from student where name='小明';
-- 查询年龄在18到20之间的所有学生
select * from student where age>18 and age<20;
select * from student where age between 18 and 20;
-- 查询除了1003外的所有学生信息
select * from student where id != 1003;
select * from student where id <> 1003;
-- 查询编号为1005或者年龄为18的学生信息
sel
版权声明:本文为weixin_34285757原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。