常用sql随笔

1039 ワード

sqlはフィールドの一部の文字を置き換え、指定した文字を置き換えます.例:列の中に2011があるものをすべて2014に修正する
update tb_zbxxid set zdgc = replace(zdgc,'2011','2014')

mysql左右切り取り
select left('  ',5) 
select right('  ',5) 

trim前後のスペースを除去

day()
month()
year()
dateiff(day,dateStr1,dateStr2) 

round(3.141593,2)      
rand()          order by rand() linit 5
count(*)     
count(  )       null      

having

group by     having where    >' '

inner join 2
left join

regexp

regexp '^[0-9{18}$]'