IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

Equivalent JOIN query for this sub-query.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
ramsri

Active User


Joined: 18 Oct 2008
Posts: 380
Location: India

PostPosted: Fri Feb 27, 2009 2:56 pm
Reply with quote

Hi,

I need an equivalent JOIN query for this below given sub-query.

Code:

SELECT ORDER_KEY, ORDER_NUM FROM DB01.CUST
 WHERE NOT EXISTS (SELECT * FROM DB01.CUST_A
                    WHERE A.ORDER_KEY = B.ORDER_KEY)



Please help. Thanks.
Back to top
View user's profile Send private message
ashimer

Active Member


Joined: 13 Feb 2004
Posts: 551
Location: Bangalore

PostPosted: Fri Feb 27, 2009 3:09 pm
Reply with quote

You are checking for an order_key from CUST which is not present in CUST_A .. you can use NOT EXISTS or NOT IN but a join wont be possible ....
Back to top
View user's profile Send private message
krithikaj

New User


Joined: 10 Aug 2008
Posts: 45
Location: India

PostPosted: Fri Feb 27, 2009 4:06 pm
Reply with quote

Hi,

Try this SQL. Use the matching column names instead of selecting all the columns in the inner query.

SELECT ORDER_KEY, ORDER_NUM
FROM DB01.CUST
WHERE NOT EXISTS
(SELECT ORDER_KEY, ORDER_NUM
FROM DB01.CUST_A
WHERE A.ORDER_KEY = B.ORDER_KEY)

Thanks
K J
Back to top
View user's profile Send private message
View previous topic :: :: View next topic  
Post new topic   Reply to topic View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts RC query -Time column CA Products 3
No new posts Dynamically pass table name to a sele... DB2 2
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Join multiple records using splice DFSORT/ICETOOL 5
Search our Forums:

Back to Top