Reputation: 83
I'm new to SQL and can't seem to get my head around a problem.
I have a table that contains the following columns: product_id, language_id, and description.
What I'm trying to do is copy data from rows where language_id is '2' and paste it to rows where the language_id is '1'.
The following code is something I tried but it produces an error:
UPDATE product_description
SET
description //incomplete bit
FROM
(
SELECT description
FROM description
WHERE language_id = 2
)
WHERE product_description.language_id = 1
Upvotes: 1
Views: 32
Reputation: 1269543
Use a join
:
UPDATE product_description pd1 JOIN
product_description pd2
ON pd1.product_id = pd2.product_id
SET pd1.description = pd2.description
WHERE pd1.language_id = 1 AND
pd2.language_id = 2;
Upvotes: 2