导航

记录mysql 的一些算子(先散乱的记录,后期整理)

Posted on 2020-04-26 22:58  少吃多动早睡  阅读(210)  评论(0)    收藏  举报

left join ,right join     使用join 会得到一张中间表,on 是来筛选中间表内容,有null 也会返回null,而where 直接将null的值过滤

inner join      获取两张表的交集

ifNull( descrption,result)  如果description=null,返回result,反之返回descrption

limit a,b     表示从第a条开始,返回b条数据

limit n    相当于 limit 0,n

distinct   列名 去重,将相同的数据过滤,只返回一条

order by  列名, desc (降序),asc(默认升序) ,一般和limit 一起使用

if(des,A,B)  如果dec为true 返回A,反之返回B 

case when   ===>>>.    col= case col when A then B  

                    ====>>>   col= case when col=A then B      有两种写法