SQL DQL查询操作

1.基本查询

sql 复制代码
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

sql 复制代码
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.聚合函数

sql 复制代码
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.分组查询

总结

相关推荐
weixin_3975740912 小时前
用自然语言查数据库出图表靠谱吗?一次智能问数实践复盘
数据库
字节跳动开源14 小时前
Viking AI 搜索 CLI 正式发布:会说话,就能做搜索推荐
数据库·人工智能·开源
TechWJ15 小时前
数据库在公司内网,出差路上想查数据怎么办?
服务器·数据库·mariadb
我是一颗柠檬15 小时前
【MySQL全面教学】MySQL事务与ACID Day9(2026年)
数据库·后端·mysql
橙子圆12315 小时前
Redis知识9之集群
数据库·redis·缓存
BlackHeart120315 小时前
【SQL】Oracle中序列(Sequence)作为默认值引发的ORA-00979
数据库·sql·oracle
bug菌16 小时前
【SpringBoot 3.x 第254节】夯爆了,数据库访问性能优化实战详解!
数据库·spring boot·后端
xxl大卡16 小时前
MySQL的执行流程
数据库·mysql
chicheese16 小时前
MySQL优化实践:选错JOIN 驱动表,性能相差几十倍
数据库·mysql
無限進步D16 小时前
MySQL 单行函数
数据库·mysql