wood burning stoves 2.0*
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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 38509
    
  23
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
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Sql query isssue