php sql交换两个主要值

时间:2016-12-01 06:55:45

标签: php jquery mysql sql

$or1='607990';
$or2='607992';

UPDATE tbl_collection
SET or_number=
    CASE
        WHEN or_number='$or1'
        THEN $or2
        WHEN or_number='$or2'
        THEN $or1 
    END
    WHERE or_number IN($or2,$or1)

//Duplicate entry '607992' for key 'PRIMARY''

2 个答案:

答案 0 :(得分:0)

perform

答案 1 :(得分:-1)

删除or_number列的主键... 无法交换具有主键

的列的值