二行數據相同列內容對換
思路:先用多表聯查的方式查詢出這二行數據,再將查詢改成修改語句,需要對換的列相互設置值。
//查詢
SELECT * fromser_ele_detail AS rule1JOIN ser_ele_detail AS rule2 ON ( rule1.account_no = rule2.account_no AND rule1.req_id = rule2.req_id ) and rule1.download_path != rule2.download_path
WHERErule1.req_id = "595f0e30b4cc493ba28a02f653e8cb7d" AND rule1.detail_id LIKE "6caeef18b002453da8c3bb12ffb296cf__";
效果圖
//修改
UPDATEser_ele_detail AS rule1JOIN ser_ele_detail AS rule2 ON ( rule1.account_no = rule2.account_no AND rule1.req_id = rule2.req_id ) and rule1.download_path != rule2.download_path
SET
//對換rule1.download_path = rule2.download_path,rule1.local_file = rule2.local_fileWHERE rule1.req_id = "595f0e30b4cc493ba28a02f653e8cb7d" and rule1.detail_id like "6caeef18b002453da8c3bb12ffb296cf__";
效果