need to retrive diff records from same table using diff crit

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
User avatar
anilanju
Member
Posts: 47
Joined: Mon Nov 10, 2008 6:59 pm

need to retrive diff records from same table using diff crit

Post by anilanju » Wed Feb 08, 2012 7:48 pm

HI

i have a table who has many col.
one col is ref as parent record and other col as its child record.

ex :
I need a record with this selection .this is a parent one
qry1 : Src='IPT' and ID='125AG'

and then below this record i need its child records which will be selected using
qry 2 : AG_ABC_SRC='IPT' AND AG_ABC_ID='125AG' .

Both the selection criterion is from same table say 'RANGE'.
What do i do to put both these condition in a single querry that i can get record first using qry 1 and then below it records using qry 2.

If i am using querry like
SELECT * FROM ABCXXX.RANGE
WHERE Src='IPT' and ID='125AG'
AND AG_ABC_SRC='IPT' AND AG_ABC_ID='125AG'

tHEN I AM GETTING NO RECORDS.

Please someone help.

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