Mysql 将表里的两列值数据互换

示例:
 

需要将表中的 两个订单号互换  

方案:
 

将同一张表数据做 临时数据 和主表 做数据交互 。


update
    表 as main,
    表 as temp
set
    main.bill_no = temp.track_bill_no,
    main.track_bill_no = temp.bill_no


where main.id = temp.id;   (等值条件)

效果:

就先到这。

猜你喜欢

转载自blog.csdn.net/qq_35387940/article/details/135384671
今日推荐