mysql 两个字段内容互换

来源:互联网 发布:静安区人民法院知询 编辑:程序博客网 时间:2024/06/17 12:35


select * from temp3 where test4 = 1




执行sql:

update temp3 as a, temp3 as b set a.test1=b.test3, a.test3=b.test1 where a.id=b.id and a.test4=1 and b.test4=1;



结果:

select * from temp3 where test4 = 1