This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes JDBC and the fly likes Sql query isssue Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Databases » JDBC
Bookmark "Sql query isssue" Watch "Sql query isssue" New topic
Author

Sql query isssue

prasad agarwal
Ranch Hand

Joined: Aug 24, 2006
Posts: 44
Why is the result-set different for both the following queries; I thought they should be the same ?



select * from p123 left outer join (p117 inner join p039 on lglstat117=lglcode039) on fnbr123=fnbr117 and refid123=refid117
and enddate117=0 where cnty123='55' and div123='4' and enddate123=0;


select * from p123 left outer join (p117 inner join p039 on lglstat117=lglcode039) on fnbr123=fnbr117 and refid123=refid117
where cnty123='55' and div123='4' and enddate123=0 and (enddate117=0 or enddate117 is null)



Your comments - very much appreciated; enddate117 is Integer type if that is of any extra help
Thanks
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38107
    
  22
In the first instance (at least I think so, I am not certain) you are doing the join on enddate117 = 0, and in the second instance you are selecting but not joining on that enddate.
Vigneswaran Marimuthu
Greenhorn

Joined: Aug 30, 2011
Posts: 24

prasad agarwal wrote:

select * from p123 left outer join (p117 inner join p039 on lglstat117=lglcode039) on fnbr123=fnbr117 and refid123=refid117
and enddate117=0 where cnty123='55' and div123='4' and enddate123=0;


select * from p123 left outer join (p117 inner join p039 on lglstat117=lglcode039) on fnbr123=fnbr117 and refid123=refid117
where cnty123='55' and div123='4' and enddate123=0 and (enddate117=0 or enddate117 is null)



Give names to the columns such that it can be easily understandable prasad !!!


Regards,

Vigneswaran.M
 
Consider Paul's rocket mass heater.
 
subject: Sql query isssue
 
Similar Threads
Theta Join
inner join Vs outer join
What are the joins in Hibernate ?
Difference between inner and outer joins
multiple tables using left outer join?