roger nall
roger nall

Reputation: 1

How to update multiple columns in one table in Oracle

I am pretty new to Oracle.I need to update two columns in one table based on different criteria from another table:

Table 1:

C1 = Hello, C2 = Jane, C3 = Goodbye, C4 = John OR
C1 = Brown, C2 = Cat, C3 = Black, C4 = Dog

Table 2:

T2.C1 = T1.C1 and T2.C2 = T1.C2 when T2.C1 = T1.C3 and T2.C2 = T1C4

I know how do this in multiple update statements. Is it possible to do this in one? If so, how?

Upvotes: 0

Views: 38

Answers (1)

AnnaS
AnnaS

Reputation: 76

UPDATE 
  (SELECT t1.c1 as c1_new, t1.c2 as C2_new, t2.c1 as c1_old, t2.c2 as c2_old
   FROM t1, t2
   WHERE t1.c3 = t2.c1 and t2.c2 = t1.c4) t
SET t.c1_old = t.c1_new, t.c2_old = t.c2_new

Upvotes: 1

Related Questions