数据库---普通查询

普通查询:
    一:查询所有数据
    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://www.cnblogs.com/0927wyj/p/5139520.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值