Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
What am I missing here?
Message
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Syntaxe SQL
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01090944
Message ID:
01090979
Vues:
10
>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
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform