dbTalk Databases Forums  

Update a table from a join with another table

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss Update a table from a join with another table in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
gimme_this_gimme_that@yahoo.com
 
Posts: n/a

Default Update a table from a join with another table - 01-17-2012 , 05:20 PM






Hello

I'd like to update the values of av.score_no to 0 where the value of
pe.avail_flag='Y'
and pe.person_id=av.person_id

Could some kind person provide a tip?

Thanks.


update score av
set av.score_no=0.0
from score av,
(
select
pe.*,
av.*
from score av
join
people pe
on av.person_id=pe.person_id
where pe.avail_flag='Y'
) b
where b.person_id=av.person_id

Reply With Quote
  #2  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: Update a table from a join with another table - 01-18-2012 , 01:12 AM






On 2012-01-18 00:20, gimme_this_gimme_that (AT) yahoo (DOT) com wrote:
Quote:
Hello

I'd like to update the values of av.score_no to 0 where the value of
pe.avail_flag='Y'
and pe.person_id=av.person_id

Could some kind person provide a tip?

Thanks.


update score av
set av.score_no=0.0
from score av,
(
select
pe.*,
av.*
from score av
join
people pe
on av.person_id=pe.person_id
where pe.avail_flag='Y'
) b
where b.person_id=av.person_id
something like:

update score av
set av.score_no=0.0
where exists (
select 1
from people pe
where av.person_id = pe.person_id
and pe.avail_flag='Y'
);

/Lennart

Reply With Quote
  #3  
Old   
gimme_this_gimme_that@yahoo.com
 
Posts: n/a

Default Re: Update a table from a join with another table - 01-18-2012 , 03:02 PM



Yay! That worked. Thanks Lennart.

Quote:
/Lennart- Hide quoted text -

- Show quoted text -

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.