update empty column according to existen data
Date: 11 Jul 2003 12:15:59 -0700
Message-ID: <a9c648ec.0307111115.14fe5ef0_at_posting.google.com>
HI, I have a question given that I have a table T
en1_id | en1 | en2_id | en2
eventually I want to update en2_id according to en1 which mean if
en2=en1 set en2_id to en1_id. If en2 is not in en1 then create a new
id for en2_id
the end table looks like
I first try to build a view
then I do update
but this give me something like
1 A (empty) B
2 B (empty) C
3 C (empty) D
en1_id | en1 | en2_id | en2
1 A 2 B
2 B 3 C
3 C 4 D
>create view VT as select * from T;
>update T
set en2_id=en1_id
where T.en2 in(select VT.en1 from VT);
1 A 1 B
2 B 2 C
3 C e D
It just set en2_id=en1_id on the same row instead of setting it to the
corresponding row.
is there any way to update the table to the way I wanted
Thanks alot !!!
Ricky Received on Fri Jul 11 2003 - 21:15:59 CEST