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 Join in SQL Query vickey_dw DB2 2 Tue Jan 17, 2017 12:15 am
This topic is locked: you cannot edit posts or make replies. MQ setup query mohitsaini Java & MQSeries 4 Sun Jan 08, 2017 1:53 am
No new posts DB2 query Using Recursion, Converting... smilewithashu2 DB2 1 Tue Jan 03, 2017 12:50 pm
No new posts SQL query to run through list of valu... Ni3-db2 DB2 14 Wed Dec 14, 2016 9:52 am
This topic is locked: you cannot edit posts or make replies. Db2 SQL query to convert rows into co... subratarec DB2 5 Thu Nov 17, 2016 4:51 pm


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