Re: Please help quick statement check
- From: Erland Sommarskog <esquel@xxxxxxxxxxxxx>
- Date: Wed, 26 Apr 2006 13:46:03 +0000 (UTC)
David (david.goodyear@xxxxxxxxx) writes:
Hi, I was hoping someone could confirm the following about the
following number 2 SQL query:
1. This extracts the data required given that there is a recording to
match the records
2. This should, but im not convinced extract all the remaining records
that do not have a matched recording, but fulfil the rest of the
criteria. If not please help...
These conditions seems to contradict each other.
3. As the two querys produce the same layout of tables if I did a UNION
ALL, this should work shouldnt it?
But why? Why not an outer join instead?
count
(
SELECT rec.*
WHERE rec.whole_phone_number = l.whole_phone_number AND
rec.last_name = l.last_name AND
rec.agent = ai.agent_login AND
rec.campaign = l.campaign
) < 1
An EXISTS clause is what you want. This is odd and less effiecient.
--
Erland Sommarskog, SQL Server MVP, esquel@xxxxxxxxxxxxx
Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/prodtechnol/sql/2005/downloads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinfo/previousversions/books.mspx
.
- Follow-Ups:
- Re: Please help quick statement check
- From: David
- Re: Please help quick statement check
- References:
- Please help quick statement check
- From: David
- Please help quick statement check
- Prev by Date: Please help quick statement check
- Next by Date: Re: SELECT and regular expression
- Previous by thread: Please help quick statement check
- Next by thread: Re: Please help quick statement check
- Index(es):
Relevant Pages
|