MySQL交换值(不在字段之间)

时间:2015-04-07 13:13:49

标签: mysql

我想请求帮助在单个字段内交换值。表格如下:

FIELD1   FIELD2
 X       HELLO
 Y       TEST

基本上我想交换X和Y值(X变为TEST,Y变为HELLO)。已经知道如何在字段之间交换或移动值,但我对此有困难。抱歉蹩脚的桌子插图。

1 个答案:

答案 0 :(得分:0)

这将成功完成您的工作

    UPDATE
rules AS rule1
JOIN rules AS rule2 ON
( rule1.rule_id = 1 AND rule2.rule_id = 4 )
SET
rule1.priority = rule2.priority,
rule2.priority = rule1.priority
;