Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
Equivalent JOIN query for this sub-query.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: Equivalent JOIN query for this sub-query.
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    Post subject:
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    Post subject: Re: Equivalent JOIN query for this sub-query.
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    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 Query to compare 2 values of 1 column... Poha Eater DB2 13 Fri Mar 09, 2018 10:45 am
No new posts How to replace the below query? pkmurali DB2 12 Tue Feb 27, 2018 9:51 pm
No new posts Need Guidance regarding UPDATE query Poha Eater DB2 3 Mon Feb 12, 2018 11:35 pm
No new posts Query to skip Max time-stamp and fetc... vickey_dw DB2 8 Sun Jan 28, 2018 1:09 am
No new posts reg query on DYNALLOC feature raghuraman123 SYNCSORT 12 Wed Jan 10, 2018 2:42 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us