首页 > 数据库技术 > 详细

数据库查询

时间:2019-12-06 09:49:59      阅读:90      评论:0      收藏:0      [点我收藏+]

6、查询所有数据

select * from Info 查所有数据

select Code,Name from Info 查特定列

 

7、根据条件查

select * from Info where Code=‘p001‘ 一个条件查询 

select * from Info where Code=‘p001‘ and Natio n=‘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 范围查询

 

8、模糊查询

select * from Car where Name like ‘%型‘ %通配符代表任意多个字符

select * from Car where Name like ‘%奥迪%‘

select * from Car where Name like ‘_马%‘ _通配符代表任意一个字符

 

9、排序

select * from Car order by Price asc 按照价格升序排列

select * from Car order by Price desc 按照价格降序排列

select * from Car order by Price,Oil 按照两列进行排序,前面的为主要的

 

10、统计函数(聚合函数)

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 取价格的平均值

数据库查询

原文:https://www.cnblogs.com/Damocless/p/11993225.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!