首頁  >  文章  >  後端開發  >  小弟我一个表A里有地个字段a b,现在数据有一部分存反了。 如何换过来

小弟我一个表A里有地个字段a b,现在数据有一部分存反了。 如何换过来

WBOY
WBOY原創
2016-06-13 13:34:33858瀏覽

求助:我一个表A里有地个字段a b,现在数据有一部分存反了。 怎么换过来
求助:我一个表A里有地个字段a b,现在数据有一部分存反了。 怎么换过来
也就是b里面数据存到更新到a里。(这个会写 下一个我就会写了),还请高手指点一下。

------解决方案--------------------

SQL code

set @tmp="";
update table set  field_a=(@tmp:=field_a), field_a=field_b,field_b=@tmp where ……
<br><font color="#e78608">------解决方案--------------------</font><br>建议用sqlyog,直接将多条语句全部执行。http://download.csdn.net/detail/dmtnewtons/4230136<br>
SQL code

update A set A.a="new_data_a",A.b="new_data_b" where A.a="old_data_a" and A.b="old_data_b";
……
<br><font color="#e78608">------解决方案--------------------</font><br>把字段名换了
<br><font color="#e78608">------解决方案--------------------</font><br>棒!<br><br>
探讨

SQL code

set @tmp="";
update table set field_a=(@tmp:=field_a), field_a=field_b,field_b=@tmp where ……
陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn