数据库的基本操作

 条件查找  where 字段=值  多条件 and or
-- select * from tb_1 where name="打算"
-- 条件查询  where 字段=值    多字段 and or
-- select * from tb_1 where name="打算" or sex="女"
-- 查询可以使用多种运算符
-- select * from tb_1 where age>50
-- select * from tb_1 where date>="2024-4-5" and date<="2024-4-25" and sex="女"

-- 范围查找 in 
-- select * from tb_1 where name in ("打算","撒旦")

-- 去重查询 distinct
-- select distinct sex from tb_1

-- 模糊查询 like  结合 占位符 %(任意字符) _(一个字符)
-- select * from tb_1 where name like "打_"
-- select * from tb_1 where name like "%阿%"
-- select * from tb_1 where age like "%3%"

-- 排序查询 order by 字段 asc(升序) | desc(降序)  多字段排序用逗号隔开
-- select * from tb_1 order by age desc,id desc   

-- 深度查询 limit 数值(开始位置)  , 数值(数量)  
-- select * from tb_1 limit 0,3

-- 一页显示两条 第一页数据
-- select * from tb_1 limit 0,2;

-- 一页显示两条 第二页数据
-- select * from tb_1 limit 2,4;

-- 聚合查询 提供聚合函数 count(字段)  数量 avg() 平均值 sum() 求和 max()求最大  min()求最小
-- select count(name) from tb_1
-- select sum(id)/min(age) from tb_1

-- 分组查询 group by 字段 having 分组后的条件
-- select sex,count(*) as 数量,max(age)  from tb_1 group by sex


 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值