IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

DB2 update query.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
krunalbafna
Warnings : 1

Active User


Joined: 18 Jan 2010
Posts: 143
Location: Pune

PostPosted: Fri Apr 16, 2010 11:53 am
Reply with quote

Hi,
following are my two tables: Table X and Table Y.

I want to update entry in table X on condition for number in table X matching Table Y.
COND: NO_tablex = No1_tableY


How shld be my query framed, May you help on this
Back to top
View user's profile Send private message
mallik4u

New User


Joined: 17 Sep 2008
Posts: 75
Location: bangalore

PostPosted: Fri Apr 16, 2010 4:34 pm
Reply with quote

Hi,

what do you mean by NUMBER here.
Is that a column present in both the tables?
Back to top
View user's profile Send private message
krunalbafna
Warnings : 1

Active User


Joined: 18 Jan 2010
Posts: 143
Location: Pune

PostPosted: Fri Apr 16, 2010 4:35 pm
Reply with quote

Number is coloum which is present in both the table..
if the coloum value is same... we need to update the entry in TABLEX
Back to top
View user's profile Send private message
mallik4u

New User


Joined: 17 Sep 2008
Posts: 75
Location: bangalore

PostPosted: Fri Apr 16, 2010 4:40 pm
Reply with quote

then you can try the following query

UPDATE X
SET <COLUMN NEEDS TO BE CHANGED> = <DESIRED VALUE>
WHERE NUMBER IN (SELECT NUMBER FROM Y)


Above query will update for all the matching NUMBER col values. If you want it to be done for specific then you may need to add WHERE clause to the inner query.
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Issue with EXEC CICS QUERY SECURITY c... CICS 6
Search our Forums:

Back to Top