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.分组查询

总结

相关推荐
老杨聊技术18 分钟前
CentOS 7 安装 MySQL 8 保姆级教程
linux·mysql·centos
sunxr.22720 分钟前
Mysql-----最后一次作业
数据库·mysql
普通网友28 分钟前
Python FastAPI 异步数据库管理
数据库·fastapi
晓子文集1 小时前
Tushare接口文档:期货合约信息表(fut_basic)
大数据·数据库·金融·金融数据·量化投资
三言老师1 小时前
CentOS7.9:Redis‑Cluster集群部署结构化实战教程
linux·运维·服务器·数据库
旺仔学长 哈哈2 小时前
Spring Boot 智能停车场管理系统---附源码+数据库文档
数据库·spring boot·后端·智能停车场
ClickHouseDB2 小时前
ClickHouse托管Postgres:OLTP+OLAP,新能力解锁最佳数据平台
java·前端·数据库
数智化管理手记3 小时前
主数据重复、错漏频发?一站式主数据管理平台如何落地?
大数据·运维·数据库·人工智能·数据挖掘
吴声子夜歌3 小时前
MongoDB 4.2——选择片键
数据库·mongodb
天天进步一点点3 小时前
QSqlQuery删除sqlite数据库执行drop数据表报错database table is locked unable to fetch row问题
数据库·oracle·sqlite