SQL update statement?
I have 2 tables. I want to insert T1 ( C3, C4) with T2 ( D3, D4) where T1.C5 = ‘09/2010’ with a SQL statements.
T1
—————-
C1 C2 C3 C4 C5
a 1 — — 09/2010
b 4 — — 08/2010
a 1 — — 09/2010
T2
—————-
D1 D2 D3 D4 D5
a 1 10 20 09/2010
b 4 50 40 08/2010
a 1 70 80 09/2010
Final Result table
T1
—————-
C1 C2 C3 C4 C5
a 1 10 20 09/2010
b 4 — — 08/2010
a 1 70 80 09/2010
Try something along the lines of
UPDATE T1
SET C3 = D3
SET C4 = D4
FROM T2 WHERE D1 = C1 AND D5 = ‘09/2010′
April 16th, 2010 at 4:52 pm
Try something along the lines of
UPDATE T1
SET C3 = D3
SET C4 = D4
FROM T2 WHERE D1 = C1 AND D5 = ‘09/2010′
References :
April 16th, 2010 at 5:00 pm
Update T1
set C4=D4, c3=d3
from T1 join T2 on c1=d1 and c2=d2 and c5=d5
where c5=‘09/2010’
References :
http://www.sql-ex.ru/help/select12.php#update