Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Column updating problem
<inlove22_at_hotmail.com> a écrit dans le message de news: 1138081707.303476.304170_at_f14g2000cwb.googlegroups.com...
| Hello,
|
| Lets say I have two tables A and B which both have the same columns PK
| ,col1, col2, col3.
| In table A there is only data in col1.The col2 and col3 columns will
| updated using the data from Table B (the tables will be joined using
| the PK column).
|
| So here is the dilenma. How do i update Table A so that I retain the
| col1 values even though Table B may not have all the col1 values and
| still update Table A's col2 and col3 with the Table B data??
|
| Table A
| PK col1 col2 col3
| 123 abc .. ..
| 234 def .. ..
| 567 ghi .. ..
|
| Table B
| PK col1 col2 col3
| 123 abc y n
| 234 n
| 567 .. y
|
| Updated Table A
| PK col1 col2 col3
| 123 abc y n
| 234 def n ..
| 567 ghi .. y
|
|
| Thanks,
|
| Thanos
|
update (select a.pk, a.col2 col2a, a.col3 col3a, b.pk, b.col2 col2b, b.col3 col3b
from tableA a, tableB b where a.pk = b.pk)
set col2a = col2b, col3a = col3b
/
Regards
Michel Cadot
Received on Tue Jan 24 2006 - 00:24:36 CST