Du kan bruge en OPDATERING med en
JOIN
til en afledt tabel for dette:
UPDATE Items AS i1
JOIN (
SELECT ID, @n := @n + 1 AS Image
FROM Items
CROSS JOIN (SELECT @n := (SELECT MAX(Image) FROM Items)) AS v
WHERE Image IS NULL
ORDER BY ID
) AS i2 ON i1.ID = i2.ID
SET i1.Image = i2.Image;
Den afledte tabel bruger variabler til at beregne Image
værdier af posterne med NULL
s.