Well, well, well!
It's SangeethaPriya R. hehe. How have you been? The code below
maybe of some help to you! Hehe.
SELECT Distinct s.st_name,
s.st_Id
FROM Station s
WHERE NOT EXISTS (select t.trng_Id from Train t
where t.trng_tra_Id='111')
NOT IN evaluates to FALSE if any member of the set is NULL. In that
case your query will not return any rows or the incorrect number of
rows.
Please take a few minutes to provide feedback on the quality of service you received from our staff. The Department of Education values your feedback as a customer. Commissioner of Education Jeanine Blomberg is committed to continuously assessing and improving the level and quality of services provided to you.Simply use the link below. Thank you in advance for completing the survey.
http://data.fldoe.org/cs/default.cfm?staff=Ed.[Email address protected]
-----Original Message-----
From: SangeethaPriya R.
[mailto:db2udbdba-ezmlmshield-x57146534.[Email address protected]
Sent: Tuesday, October 30, 2007 6:52 AM
To: LazyDBA Discussion
Subject: Reg. Implementing Join with Not in Condition
Hi All,
Please tell me how to replace the following sql query into sql-join for
the following query.
SELECT Distinct s.st_name,
s.st_Id
FROM Station s
WHERE s.stn_Id not in
(select t.trng_Id from Train t where t.trng_tra_Id='111')
The above query feches the rows: 272
I tried to convert like below. But the result shows it different from
the above query.
SELECT Distinct s.st_name,
s.st_Id
FROM Station s
Left Outer Join train t
on s.stn_Id = t.trng_Id
and t.trng_tra_Id='111'
The above query fetches 274 rows (ie., all the rows in Station s
table.).
Please Help me on this.
Thanks in Advance,
Regards,
R. Sangeetha Priya
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
To post a dba job: http://jobs.lazydba.com
To Subscribe : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
DB2 & UDB email list listserv db2-l LazyDBA home page