Mysql exchanges two column value data in the table

Example:
 

Need to exchange the two order numbers in the table  

plan:
 

Use the same table data as temporary data and interact with the main table.


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; (equivalent condition)

Effect:

Just come here first.

Guess you like

Origin blog.csdn.net/qq_35387940/article/details/135384671