项目四总结:MySQL数据库的检索

1,聚合函数

数量 select count (字段名)count (*、0)from 表名;

 

求和 select sum (字段名)from 表名;

平均值 select avg (字段名)from 表名;

 

 

最小值 select min (字段名) from 表名;

最大值 select max (字段名)from 表名;

 

分组 select 字段名,group by 字段名 having 条件;

 

2,为字段名取别名 (as可以省略)

select 字段名 (as)字段别名 from 表名 group by字段名;

 

3,表与表的连接

交叉连接

select * from 表名1 cross join 表名2;

 

内连接

select * from 表名1 inner join 表名2 on 表名1.表1字段名=表名2.表2字段名;

左连接

select * from 表名1 left join 表名2 on 表名1字段名= 表名2.表2字段名;

 

 

右连接

select * from 表名1 right join 表名2 on 表名1字段名= 表名2.表2字段名;

 

4,子查询 in

select * from 表名 where 字段 in(查询语句);

 

子查询 exists

select * from 表名 where exists (查询语句);

 

子查询 any

select * from 表名 where 字段>any(查询语句);

 

子查询 all

select * from 表名 where 字段>all (查询语句);

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值