测试人员必会MySQL的简单查询语句

上一篇 / 下一篇  2018-07-02 09:28:03 / 个人分类:第二博客


 1 | 查询所有数据 


select * from Info 查所有数据

select Code,Name from Info 查特定列



 2 | 根据条件查 


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 范围查询



 3 | 模糊查询 


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

select * from Car where Name like '%奥迪%' _通配符代表任意一个字符

select * from Car where Name like '_马%'



 4| 排序 


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

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

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


 5 | 统计函数(聚合函数)


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



 6 | 分组查询 


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



 7 | 分页查询 


select * from Car limit 0,5 跳过几条数据取几条数据



 8 | 去重查询 


select distinct Brand from Car


TAG:

引用 删除 2243148804   /   2018-08-23 16:23:06
5
引用 删除 609066189   /   2018-07-20 14:14:30
5
引用 删除 chengxiao0501   /   2018-07-12 16:21:42
5
Fighting-ing的个人空间 引用 删除 Fighting-ing   /   2018-07-03 14:52:22
5
引用 删除 langdawang678   /   2018-07-03 10:19:57
5
 

评分:0

我来说两句

binning_001

binning_001

因为不是天生丽质,所以必须天生励志

我的栏目

日历

« 2024-03-27  
     12
3456789
10111213141516
17181920212223
24252627282930
31      

数据统计

  • 访问量: 87252
  • 日志数: 66
  • 建立时间: 2008-04-20
  • 更新时间: 2019-02-23

RSS订阅

Open Toolbar