Move Duplicate Values To Another Column
I have a table with pairs of entries based on the column id_location. 'id_image', 'score', 'stddev', 'id_image2', 'score2', 'stddev2', 'id_location' 3484, 0.90422, 0.0647
Solution 1:
This would do it, with the higher id_image appearing in the first slot:
INSERT INTO new_table
SELECT t1.id_image, t1.score, t1.stddev, t2.id_image,
t2.score, t2.stddev, t1.id_location
FROM old_table t1
JOIN old_table t2
ON t2.id_location = t1.id_location
AND t2.id_image < t1.id_image
Solution 2:
Maybe using subqueries :
UPDATE your_table
SET
score2 = (SELECT score FROM your_table WHERE id_image = 3484),
stddev2 = (SELECT stddev FROM your_table WHERE id_image = 3484),
WHERE id_image = 18;
Post a Comment for "Move Duplicate Values To Another Column"