SQL DQL查询操作
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.分组查询
总结
原文地址:https://blog.csdn.net/python_136/article/details/143887131
免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!