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

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

WBOY
Release: 2016-06-13 13:34:33
Original
908 people have browsed it

求助:我一个表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>
Copy after login
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>
Copy after login
探讨

SQL code

set @tmp="";
update table set field_a=(@tmp:=field_a), field_a=field_b,field_b=@tmp where ……
Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template