Wrox Programmer Forums Difference Between This Two Query's
 |
BOOK: Beginning SQL
 This is the forum to discuss the Wrox book Beginning SQL by Paul Wilton, John Colby; ISBN: 9780764577321 Read more about Beginning SQL or buy the book from your favorite retailer Download the code for Beginning SQL
 Welcome to the p2p.wrox.com Forums. You are currently viewing the BOOK: Beginning SQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com

September 18th, 2008, 06:45 PM
 msmiran Registered User Join Date: Sep 2008 Posts: 2 Thanks: 0 Thanked 0 Times in 0 Posts
Difference Between This Two Query's

Hello All,

I write this query for Exercise 2 from Chapter 8 :
Code:
```SELECT City, State
FROM MemberDetails AS MD1
WHERE(SELECT COUNT(*) FROM MemberDetails AS MD2 WHERE MD2.City = MD1.City
AND MD2.State = MD1.State) >= 2
AND MD1.City NOT IN (SELECT City FROM Location)
GROUP BY City, State;```
And book answer use from Exists Operator :

Code:
```SELECT City, State FROM MemberDetails AS MD1
WHERE(SELECT COUNT(*) FROM MemberDetails AS MD2
WHERE NOT EXISTS (SELECT * FROM Location AS L1 WHERE L1.City = MD2.City AND
L1.State = MD2.State)
AND MD1.City = MD2.City AND MD1.State = MD2.State
GROUP BY City,State)>=2
GROUP BY City,State ;```
Please comparison this Query's in Speed and etc.

Thanks My Friends.:)

 Similar Threads Thread Thread Starter Forum Replies Last Post Is there a difference? ironchef Java Basics 2 October 6th, 2006 03:26 AM difference Y.Hashmi ADO.NET 1 September 19th, 2006 07:02 PM How to check if query's are present in a database rmsmit VB How-To 6 December 13th, 2005 11:48 AM what is the difference? chuck_schuldiner Javascript How-To 2 February 10th, 2005 01:46 AM what is the difference between... chuck_schuldiner Javascript 2 February 10th, 2005 01:41 AM