Maison  >  Article  >  développement back-end  >  小弟我一个表A里有地个字段a b,现在数据有一部分存反了。 如何换过来

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

WBOY
WBOYoriginal
2016-06-13 13:34:33858parcourir

求助:我一个表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 ……
Déclaration:
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn