基础语句:
模糊匹配:
% 任意字符,_占位符
like '_t%';
多字段排序:
select winner,yr,subject from nobel where winner like 'Sir%' order by yr desc,winner asc
按照特殊排序,把chemistry,physics排在后面
select winner,subject from nobel where yr = 1984 order by subject in ('chemistry','physics') ,subject, winner
limit限制范围:
select name,population from world
order by population desc
limit 3,4
sg:从第4行到第7行的数据
聚合函数忽略空值
某个字段包含另外字段 可以用concat+like进行筛选
高级语句:
窗口函数、子查询、表链接
窗口函数相当于把having后面的数据拿去新窗口操作再返回到原表,不影响原表排序
over([partition by xxx] order by xxx)
只能写在select里面,而且分区不去重