Reg. Implementing Join with Not in Condition

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


DB2 & UDB email list listserv db2-l LazyDBA home page