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

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

WBOY
WBOYOriginal
2016-06-13 10:18:10900browse

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

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

SQL code
set @tmp="";update table set  field_a=(@tmp:=field_a), field_a=field_b,[email protected] 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,[email protected] where ……
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn