mysql同一张表查询并更新

update hsx_statistic_messages as updatetable INNER JOIN (select id, SUBSTRING_INDEX(deviceNum,'-',1) AS dmin,SUBSTRING_INDEX(deviceNum,'-',-1) AS dmax from hsx_statistic_messages) as originaltable on originaltable.id=updatetable.id set updatetable.device_minnum=originaltable.dmin,updatetable.device_maxnum=originaltable.dmax

 

转载于:https://my.oschina.net/renshengwudi/blog/807122

你可能感兴趣的:(mysql同一张表查询并更新)