Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

Inner Join query

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
sree reddy

New User


Joined: 20 Jul 2007
Posts: 27
Location: bangalore

PostPosted: Tue Aug 18, 2009 10:59 pm    Post subject: Inner Join query
Reply with quote

I have 3 tables

1. a tabel(table 1)

a Cycle-event-id (Primary Key)
b cut-date
c cut-code

2. b table (table 2)

a pay id (primary key)
b cycle-event-id (foreigh key)
c b-code
d b-name
e b-phone-number
f b-comment
g b-status
h b-pharm-id

3. C table(table 3)

a root-id (primary key)
b pay id (foreigh key)
c cust-id
d g-num
e res
f text
g cust -aff

Select a. Cycle_event_id
B. pay_id
B. b_PHONE_NBR,
B. b_name,
B. b_note,
B. b_Code,
B. b_comment,
B. b-status
c. Cut_AFF,
c. CUST_ID,
c.PAYMENT_GRP_NBR,
c. RESP_PERCENT


from a

where

a .CUT_DT = :WS-HOLD-CUT-DATE
AND
a.CUT_Code = :WS-HOLD-cut-code

inner join b

on a.CYCle_EVENT_ID = B._CYC_EVENT_ID


Inner join C
on B. pay-id = c-pay-id
-----

The input to this query is WS-HOLD-CUT-DATE, WS-HOLD-cut-code

Can anyone suggest if this query is right , i cannot test this since the tables are not yet built

Thanks
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: Wed Aug 19, 2009 12:37 am    Post subject:
Reply with quote

Hello,

Quote:
i cannot test this since the tables are not yet built
If you'd like to test queries before the "real" environment is set up, you might consider:
http://www-01.ibm.com/software/data/db2/express/download.html

You could install this on a pc and do lots of things. . .
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Wed Aug 19, 2009 1:39 pm    Post subject:
Reply with quote

Quote:

from a

where

a .CUT_DT = :WS-HOLD-CUT-DATE
AND
a.CUT_Code = :WS-HOLD-cut-code

inner join b

on a.CYCle_EVENT_ID = B._CYC_EVENT_ID

Inner join C
on B. pay-id = c-pay-id



Rearranging a bit would help you ..

Code:

from a

inner join b

on a.CYCle_EVENT_ID = B._CYC_EVENT_ID


Inner join C
on B. pay-id = c-pay-id
where

a .CUT_DT = :WS-HOLD-CUT-DATE
AND
a.CUT_Code = :WS-HOLD-cut-code
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 JCL to Set Return code based on DB2 S... vinu78 DB2 17 Mon Mar 13, 2017 9:47 pm
No new posts Join giving more records than expected Danielle.Filteau SYNCSORT 2 Thu Mar 09, 2017 3:28 am
No new posts SQL query not working in Cobol program. CuriousMainframer COBOL Programming 14 Wed Feb 22, 2017 5:56 pm
No new posts Omegamon for DB2 query ashek15 DB2 0 Wed Feb 15, 2017 11:25 am
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us