Go Back   CodingForums.com > :: Server side development > MySQL > Other Databases

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 07-06-2012, 09:25 PM   PM User | #1
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Oracle 10g LEFT OUTER JOIN issue

Hello, everyone.

I am new to Oracle (I have mostly MS-SQL experience) and have an issue that has me stumped.

LEFT OUTER JOIN is supposed to grab everything from the LEFT table that matches the WHERE clause, regardless of whether or not there is any corresponding data in the RIGHT table. I have a query that when run strictly on the LEFT table will produce 26 records; but when I include the code for the JOIN, I get nothing. Could someone please look at these and tell me what I am doing incorrectly?

Here is the code that is just for the LEFT table:
Code:
SELECT a.edu_id, a.edu_title, a.edu_desc_tx, a.app_nm, a.edu_prereq
FROM tableA a
WHERE a.trn_app_id = 3
    AND a.edu_status = 'Y'
ORDER BY a.edu_reorder_id
This will return 26 records.

If I make it with the LEFT OUTER JOIN, I get ZERO records:
Code:
SELECT a.edu_id, a.edu_title, a.edu_desc_tx, a.app_nm, a.edu_prereq,
    b.class_id, b.class_start_date, b.class_end_date
FROM tableA a LEFT OUTER JOIN tableB b ON b.edu_id = a.edu_id
WHERE a.trn_app_id = 3
    AND a.edu_status = 'Y'
    AND b.class_status = 'Y'
    AND b.class_start_date > sysdate
ORDER BY a.edu_reorder_id, b.class_start_date
Thank you,
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".
WolfShade is offline   Reply With Quote
Old 07-06-2012, 11:51 PM   PM User | #2
guelphdad
Super Moderator


 
guelphdad's Avatar
 
Join Date: Mar 2006
Location: St. Catharines, Ontario Canada
Posts: 2,629
Thanks: 4
Thanked 147 Times in 138 Posts
guelphdad will become famous soon enoughguelphdad will become famous soon enough
All of the conditions on the second table (table b in this case) belong in the ON clause and not in the WHERE clause.
guelphdad is offline   Reply With Quote
Users who have thanked guelphdad for this post:
WolfShade (07-09-2012)
Old 07-09-2012, 04:28 PM   PM User | #3
WolfShade
Regular Coder

 
Join Date: Apr 2012
Location: St. Louis, MO, USA
Posts: 960
Thanks: 7
Thanked 100 Times in 100 Posts
WolfShade is an unknown quantity at this point
Resolved

I'm going to have a huge, red handprint on my forehead as soon as I'm done typing.

Thank you, guelphdad. That was exactly my issue.
__________________
^_^

If anyone knows of a website that can offer ColdFusion help that isn't controlled by neurotic, pedantic jerks* (stackoverflow.com), please PM me with a link.
*
The neurotic, pedantic jerks are not the owners; just the people who are in control of the "popularity contest".

Last edited by WolfShade; 07-09-2012 at 10:06 PM..
WolfShade is offline   Reply With Quote
Reply

Bookmarks

Tags
join, left, oracle, outer

Jump To Top of Thread


Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 05:39 AM.


Advertisement
Log in to turn off these ads.