MySql语句备忘 UPDATE

在mysql中,不能直接使用set select的结果,必须使用inner join:

update tb1 inner join (select `字段` from tb2)  tb3 on tb1.id =tb2.id  set tb1.`字段1` = tb3.`字段1`

在sql server中,我们可是使用以下update语句对表进行更新:

update a set a.xx= (select yy from b) where a.id = b.id ;

 

类似JSON解析,MySql 5.6

-- fs_pay_info json 字符串  

-- "90003": key   

-- SUBSTRING(str,index,length)  

-- LOCATE(subStr,str,startIndex)  

SUBSTRING(fs_pay_info,LOCATE('"90003":',fs_pay_info)+8,IF(LOCATE(',',fs_pay_info,2) =0,LOCATE('}',fs_pay_info,2),LOCATE(',',fs_pay_info,2))-(LOCATE('"90003":',fs_pay_info)+8)) AS freeamnt  

 

posted @ 2018-01-22 09:57  dongzhou  阅读(93)  评论(0编辑  收藏  举报