ShMiL
03-23-2007, 02:58 PM
I'm trying to update the table [faq].
This works ok (no order change).
UPDATE faq SET orderID = CASE id
WHEN 1 then 0
WHEN 2 then 1
WHEN 3 then 2
WHEN 5 then 3
WHEN 4 then 4
WHEN 6 then 5
ELSE orderID END
But when I try to change the order, like this:
UPDATE faq SET orderID = CASE id
WHEN 1 THEN 0
WHEN 2 THEN 1
WHEN 3 THEN 2
WHEN 5 THEN 3
WHEN 4 THEN 4
WHEN 6 THEN 5
ELSE orderID END
I get this error:
Duplicate entry '4' for key 'orderID'
How is that?
Thanks
This works ok (no order change).
UPDATE faq SET orderID = CASE id
WHEN 1 then 0
WHEN 2 then 1
WHEN 3 then 2
WHEN 5 then 3
WHEN 4 then 4
WHEN 6 then 5
ELSE orderID END
But when I try to change the order, like this:
UPDATE faq SET orderID = CASE id
WHEN 1 THEN 0
WHEN 2 THEN 1
WHEN 3 THEN 2
WHEN 5 THEN 3
WHEN 4 THEN 4
WHEN 6 THEN 5
ELSE orderID END
I get this error:
Duplicate entry '4' for key 'orderID'
How is that?
Thanks