1.基本查询
select name,employee.workno,employee.age from employee;select employee.idcard as '身份证号' from employee;select employee.entrydate from employee;
select distinct employee.entrydate from employee;
2.条件查询 where
select * from employee where idcard is null;
select employee.age from employee where age between 12 and 21;
select * from employee where age = 12 or age=17 or age =19;
select age from employee where age in (12,17,19)# 模糊匹配 like _ %
select employee.name from employee where name like '__';# 任意个字符
select employee.name from employee where name like 'i%';
3.聚合函数
select count(name) from employee;
select avg(employee.age) as '平均年龄' from employee;
select max(employee.age) from employee;
select max(employee.age) from employee;
select min(employee.age) from employee;
select sum(employee.age) from employee where entrydate='2018-01-01';
所有的null不参与聚合函数的计算
4.分组查询
总结