mysql-SQL基础

sql在线练习网站 http://sqlzoo.net/wiki/SELECT_basics/zh

在线sql教程 https://www.1keydata.com/cn/sql/

1.模糊搜索

select * from world where continent like ‘As%’;

2.两个条件 and,or

select * from world where area=468 or area=28748;

3.限制 in

select * from world where area in (468,28748);

4.在范围内

select * from world where area between 0 and 200;

5.排序

select * from world where area between 0 and 200 order by area asc;

6.函数

select avg(area) from world where area between 0 and 200;

avg()平均值,count()计数,max()最大值,min()最小值,sum()总和

7.搜索不重复项

select distinct area from world where area between 0 and 200;

8.分组统计

select name,sum(area) from world group by name;

9.为函数设置条件

select name,sum(area) from world group by name having sum(area)<10000;

10.别名

select name my_name,sum(area) from world group by name having sum(area)<10000;

    原文作者:知孺
    原文地址: https://www.jianshu.com/p/753a9f0685bf
    本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系博主进行删除。
点赞