-
Hi ,
Please check this out :
===========================
create table table_a
(
cola int,
colb varchar(100)
);
create table table_b
(
cola int,
colb varchar(100)
);
insert into table_a values ( 1, 'Line 1');
insert into table_a values ( 2, 'Line 2');
insert into table_a values ( 3, 'Line 3');
insert into table_a values ( 4, 'Line 4');
insert into table_b values ( 3, 'Line 3 from Table B');
insert into table_b values ( 4, 'Line 4 from Table B');
--Doesn't work
update table_a
set colb = table_b.colb
from table_a , table_b
where cola = table_b.cola
>> gives error ORA-00933: then somebody said oracle doesn't like it. ORACLE SUCKS :( it works in other RDBMS
-- this should work , but it mess up with the rows which does not macth ( update with NULL ), see the result
update table_a
set colb =
(
select table_b.colb
from table_b
where table_a.cola = table_b.cola
)
it gives :
COLA COLB
1 [NULL]
2 [NULL]
3 Line 3 from Table B
4 Line 4 from Table B
which is wrong , can somebody help here
DBKID
-
update table_a
set colb =
(
select table_b.colb
from table_b
where table_a.cola = table_b.cola
)
where
exists
(select 1 from table_b where table_a.cola=table_b.cola);
this is the first time i post reply.
i am on my way to guru.
:-)
guru is on the way!!!!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|