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
 
Insert into a table by selecting from 2 tables

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
poongs
Warnings : 1

New User


Joined: 24 Jan 2007
Posts: 28
Location: pune

PostPosted: Tue May 13, 2008 9:49 am    Post subject: Insert into a table by selecting from 2 tables
Reply with quote

I have 3 tables say A, B and C. Tables A and B are similar with columns having same datatypes except that table B has an additional column. I would like to get the details of this additional colum from table C.

The functionality needs to be something like the one below

For ex, if table A has columns 1,2,3,4

Insert into A
(select 1,2,3 from table B (and for the 4th column) select 4 from table C)
Back to top
View user's profile Send private message

sainathvinod

New User


Joined: 01 Apr 2008
Posts: 11
Location: Chennai

PostPosted: Tue May 13, 2008 9:59 am    Post subject:
Reply with quote

Could you please make you question a bit more clear?
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue May 13, 2008 10:25 am    Post subject:
Reply with quote

Hello,

To best receive suggestions that will provide a solution to your requirement, you need to post some sample rows from the tables and what the outcome should be of processing those rows.

Include both rows that will cause an insert in tableA and rows that will not. Once you show approprite data and clearly explain the "rules", you wil receive something useful rather than more questons.
Back to top
View user's profile Send private message
sainathvinod

New User


Joined: 01 Apr 2008
Posts: 11
Location: Chennai

PostPosted: Tue May 13, 2008 10:59 am    Post subject:
Reply with quote

Please try this query........ I'm not sure if my understanding is correct:-

INSERT INTO A
(SELECT B.1,
B.2,
B.3,
C.4
FROM B,C
WHERE B.(JOINING FIELD WITH TABLE C) = C.(CORRESPONDING JOINING FIELD WITH TABLE B)
)
Back to top
View user's profile Send private message
dick scherrer

Site Director


Joined: 23 Nov 2006
Posts: 19270
Location: Inside the Matrix

PostPosted: Tue May 13, 2008 11:10 am    Post subject: Reply to: Insert into a table by selecting from 2 tables
Reply with quote

Hello Sainath,

Quote:
I'm not sure if my understanding is correct:-
I wasn't sure either icon_confused.gif Which is why i asked for clarification.

Hopefully, your understanding is correct icon_wink.gif

d
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 Selecting a row from multiple tables! Vignesh Sid DB2 2 Thu Oct 26, 2017 6:09 pm
No new posts Update table without cursor Ron Klop DB2 3 Wed Oct 11, 2017 1:06 pm
No new posts Table(Unicode(Graphic) table) loading... muralikrishnan_new DB2 0 Thu Oct 05, 2017 5:10 pm
No new posts How to insert a value on specific pos... Poha Eater DFSORT/ICETOOL 9 Sun Oct 01, 2017 3:04 am
No new posts Insert a Row_number into table useit DB2 2 Tue Sep 19, 2017 1:07 pm

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