Reputation: 1569
I have two tables nol_art and #tmpIzm I want to update nol_art with value from table #tmpIzm if it's not null otherwise the value stays unchanged
The code that I wrote, but there are some mistake, so it does not work:
update nol_art
set
CENA_IZM=if(xd.IZM IS NULL,' ',xd.IZM)
from
#tmpIzm xd
join nol_art a on a.ART_ID=xd.ID_ART
where
a.ART_ID=xd.ID_ART
Upvotes: 1
Views: 110
Reputation: 115
I did it in DB2
UPDATE
document
SET
department =
(SELECT departmentId
FROM
department
WHERE
document.base_child = document.base_child AND
document.folder_child = document.folder_child)
WHERE
EXISTS
( SELECT * FROM department
WHERE department.base_child = department.base_child
AND department.folder_child = department.folder_child);
hope to help
Upvotes: 1
Reputation: 2885
Try this:
update nol_art
set
CENA_IZM=coalesce(xd.IZM, CENA_IZM)
from
#tmpIzm xd
join nol_art a on a.ART_ID=xd.ID_ART
where
a.ART_ID=xd.ID_ART
Upvotes: 3