Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

DB2 update query.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: DB2 update query.
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    Post subject:
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    Post subject:
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    Post subject:
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
No new posts -913/-911 Deadlock during UPDATE stat... NoSleep319 DB2 5 Fri Nov 18, 2016 12:37 am


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us