`

MSSQL和MySQL中,数据表两列字段值互换的问题,记录下

 
阅读更多

MSSQL的处理方法
update table1
set field_1 = field_2, field_2 = field_1
可是MySQL就不能这样写,不然一列会覆盖另一列记录
MySQL语句如下
update table1 a, table1 b
set a.field_1 = b.field_2, a.field_2 = b.field_1
where a.id = b.id


mysql

update sy_subscribe t , sy_subscribe t1 set  t.source_keyword= t1.source_id , t.source_id = t1.source_keyword ,t.unique_id = CONCAT(t1.source_id,'_',t1.source_keyword)
where t.subscribe_id = t1.subscribe_id and t.subscribe_id =1209
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics