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
Titre:
What am I missing here?
Versions des environnements
SQL Server:
SQL Server 2000
Divers
Thread ID:
01090944
Message ID:
01090944
Vues:
51
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
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

select ch.* from tblclaimheader ch where not exists (select * from tbllocation L where l.ilsid = ch.ilsid)
-- returns 1841 records
select * from tblclaimheader where ilsid = 1
-- returns 1 record
select * from tbllocation where ilsid = 1
-- returns no records
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform