Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: Column updating problem

Re: Column updating problem

From: <inlove22_at_hotmail.com>
Date: 24 Jan 2006 08:58:00 -0800
Message-ID: <1138121880.388529.124810@z14g2000cwz.googlegroups.com>


Hi Mike,

Sorry but i made an error....i scenerio is also that some of the col1 data changed. I've updated the tables below for a better understanding.

 Table A

 PK        col1       col2      col3
 123       abc         ..           ..
 234       def          ..           ..
 567       ghi          ..           ..

 Table B
 PK        col1       col2      col3
 123       xyz         y          n
 234                     n
 567                     ..           y

 Updated Table A
 PK        col1       col2      col3
 123       xyz         y           n
 234       def          n           ..
 567       ghi          ..           y



Michel Cadot wrote:
> <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 - 10:58:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US