I have a large table of records where the primary key is an item code which is an int.
Lots of the records are out of date and I want to replace the information in those rows with information in other rows while keeping the old primary key.
So if I had two rows:
ITEM_CODE LANGUAGE LABEL
12345678 ENG OLD LABEL
87654321 EN-GB NEW LABEL
Im looking to write an SQL statement that will leave me with the following table
ITEM_CODE LANGUAGE LABEL
12345678 EN-GB NEW LABEL
87654321 EN-GB NEW LABEL
When I looked at the UPDATE statement I was looking for something like
UPDATE table
SET language1 and label1 WITH language2 and label 2
WHERE item code1 = item code 2
Im doing this all in SQL Server Management Studio
Hope you can help. Thanks
change your code like below:
UPDATE table SET LANGUAGE = (Select LANGUAGE from table where ITEM_CODE = 87654321)
LABEL = (Select LABEL from table where ITEM_CODE = 87654321)
WHERE ITEM_CODE = 12345678
it will work for your example, also you can rewrite it in other syntax and ways.....
if you are a different goal, please explain it more.
good luck
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.