please send me the query

Ask question on - DataBase Concepts, IBM Mainframe DB2, DB2/UDB, DB2 Tools, SQL , DB2 programming with languages like COBOL, PL1.

Moderators: Kalicharan, Moderator Group

Post Reply
mvivekm21
Member
Posts: 1
Joined: Fri Jun 01, 2012 6:02 pm

please send me the query

Post by mvivekm21 » Tue Jun 05, 2012 8:29 pm

in db2, i m having the two tables. both tables have no primary key. duplicates are there.
how to fetch the multiple rows from 1st table and insert into the 2nd by comparing the two fields in first table.
mvivekm21

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Tue Jun 05, 2012 11:07 pm

Your request is not clear.

Suggest you show a few sample rows from both tables and what should be the result when your query is run.

No need for a lot of volume, but enough to show the different possibilities. Only relevant columns need to be showm.
Have a good one

NicC
Active Member
Posts: 650
Joined: Sun Jul 24, 2011 5:27 pm
Location: Down on the pig farm

Post by NicC » Wed Jun 06, 2012 10:48 am

Please send the money
Regards
Nic

Anuj Dhawan
Moderator
Posts: 1625
Joined: Sat Aug 09, 2008 9:02 am
Location: Mumbai, India

Post by Anuj Dhawan » Wed Jun 06, 2012 11:45 am

Well - your subject title seems to be a winner!

And as far as I can make out of your question - most possibly you can use JOIN but then to use that you just tell this
fetch the multiple rows from 1st table
which is not at all sufficient to answer your question, as DikDude also indicates.
Regards,
Anuj

cmsmoon
Member
Posts: 3
Joined: Mon Jun 18, 2012 4:00 pm

Post by cmsmoon » Mon Jun 18, 2012 4:21 pm

INSERT INTO TABLE2 VALUES(COL1,COL2,COL3) SELECT COL1,COL2,COL3 FROM TABLE1 WHERE COL1 = COL3 ;

INSERT INTO T2 (intcol1,identcol2) SELECT intcol1, identcol2
FROM T1
Please refer
http://publib.boulder.ibm.com/infocente ... 000970.htm

DikDude
Moderator
Posts: 1001
Joined: Fri Jul 22, 2011 8:39 am
Location: usa

Post by DikDude » Mon Jun 18, 2012 8:28 pm

Did you test the inserts before posting?

How do you know this is what the TS wants?
Have a good one

Post Reply

FREE TUTORIALS

Tutorials
Free tutorials from mainframegurukul
  • JCL Tutorial
    Covers all important JCL concepts.
  • Cobol Tutorial
    This tutorials covers all Cobol Topics from STRING to COMP-3.
  • DB2 Tutorial
    DB2 Tutorial focuses on DB2 COBOL Programming.
  • SORT Tutorial
    This Tutorial covers all important aspects of DFSORT with examples
  • CICS Tutorial
    This CICS tutorial covers CICS concepts and CICS Basics, CICS COBOL Programming.
Interview
Mainframe Interview questions



Other References
Mainframe Tools and others