Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts HEX value search in a DB2 query maxsubrat DB2 2 Wed Oct 04, 2017 3:04 pm
No new posts Create procedure issues -628 when add... chandraBE DB2 1 Mon Sep 18, 2017 12:16 pm
No new posts Can we limit length in concatenation ... balaji81_k DB2 7 Tue Aug 22, 2017 2:50 am
No new posts Need DB2 query to fetch previous row ! Chandan1993 DB2 10 Sat Jun 03, 2017 10:43 am

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us