前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >MySQL的简单查询语句「建议收藏」

MySQL的简单查询语句「建议收藏」

作者头像
全栈程序员站长
发布2022-07-01 19:02:06
7700
发布2022-07-01 19:02:06
举报

大家好,又见面了,我是你们的朋友全栈君。

查询: 一:查询所有数据 select * from Info 查所有数据 select Code,Name from Info 查特定列

二:根据条件查 select * from Info where Code=’p001′ 一个条件查询 select * from Info where Code=’p001′ and Nation=’n001′ 多条件 并关系 查询 select * from Info where Name=’胡军’ or Nation=’n001′ 多条件 或关系 查询 select * from Car where Price>=50 and Price<=60 范围查询 select * from Car where Price between 50 and 60 范围查询

三:模糊查询 select * from Car where Name like ‘%型’ %通配符代表任意多个字符 select * from Car where Name like ‘%奥迪%’ _通配符代表任意一个字符 select * from Car where Name like ‘_马%’

四:排序 select * from Car order by Price asc 按照价格升序排列 select * from Car order by Price desc 按照价格降序排列 select * from Car order by Price,Oil 按照两列进行排序,前面的为主要的

五:统计函数(聚合函数) select count(Code) from Car 查询表中有多少条数据 select max(Price) from Car 取价格的最大值 select min(Price) from Car 取价格的最小值 select sum(Price) from Car 取价格的总和 select avg(Price) from Car 取价格的平均值

六:分组查询 select Brand from Car group by Brand having count(*)>2 查询所有系列中数量大于2的

七:分页查询 select * from Car limit 0,5 跳过几条数据取几条数据

八:去重查询 select distinct Brand from Car

发布者:全栈程序员栈长,转载请注明出处:https://javaforall.cn/147266.html原文链接:https://javaforall.cn

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档