Mysql Select 查询完整语法

selet[select 选项] 
    字段列表[字段别名] /* 
from 数据源
left join xxx on xxxx
[where条件字句]
[group by 字句]
[having 字句]
[order by 字句]
[limit 字句]




字段列表 字段别名!!!!!

select xx 别名,xxx 

 

 

if (aaa like 'Fid%',substring(aaa, 6, 8),aaa) newaaa

split 不方便则用 substring 

mysql if

 

< 40 40到60之间 大于60 

case when score <40 then 'xxx'

when score <60 then 'dddd'

when score>60 then 'ccc'

end as newScore

week(dt) 一年中的第几周

select yearweek('2020-01-08',1)

返回年和第几周

20200102

 

sql in 查询 在按照in里面的顺序进行输出

SELECT orderId from order  WHERE orderId in (051,038,050) order by field(orderId,051,038,050)
 

 

你可能感兴趣的:(mysql)