Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
What am I missing here?
Message
General information
Forum:
Microsoft SQL Server
Category:
SQL syntax
Environment versions
SQL Server:
SQL Server 2000
Miscellaneous
Thread ID:
01090944
Message ID:
01090979
Views:
11
>What is the difference in IN (select..) and exists? Whe does the first query return nothing but the second one does?
>Thanks
>
>-- tblclaimheader.ilsid and tbllocation.ilsid are both int(4)
>
>select * from tblclaimheader ch
>    where ch.ilsid not in (select l.ilsid from tbllocation L)
>-- returns no records

 ???? ARE YOU SURE ???? MUST RETURN 1 OR MORE ROWS

>select * from tblclaimheader ch where ch.ilsid = 1 and
>	 ch.ilsid not in (select l.ilsid from tbllocation L where l.ilsid = 1)
>-- returns 1 record

can be
>
>select ch.* from tblclaimheader ch where not exists (select * from tbllocation L where l.ilsid = ch.ilsid)
>-- returns 1841 records

can be
>select * from tblclaimheader where ilsid = 1
>-- returns 1 record

sure

>select * from tbllocation where ilsid = 1
>-- returns no records

sure
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform