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 SYSIBM Catlog tables to see DDL chang... rakesh17684 DB2 0 Fri Jun 08, 2018 3:43 am
No new posts Extracting DDL for all list of intere... Ashishpanpaliya DB2 5 Mon May 21, 2018 4:08 pm
No new posts Searching a table for the field name? socker_dad COBOL Programming 8 Sat Mar 31, 2018 2:57 am
No new posts Need inputs on DB2 tablespace/table r... ashek15 DB2 3 Sat Mar 24, 2018 11:49 pm
No new posts COBOL declaration for table Poha Eater DB2 3 Mon Feb 26, 2018 6:58 pm

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