If you're using SQL Server, you could rewrite your query like this:

SELECT s.shopperID
FROM tblShopper s
WHERE NOT EXISTS (SELECT * FROM tblorder o where o.shopperID = s.shopperID)

~Dina



----- Original Message ----- 
  From: Eric Creese 
  To: CF-Talk 
  Sent: Friday, January 10, 2003 10:15 AM
  Subject: Help with a query.


  I would do the following

  SELECT tblShopper.shopperID
  FROM tblShopper
  WHERE shopperID NOT IN (SELECT DISTINCT tblOrder.shopperid FROM tblorder)

  Not sure what DB your using but using a NOT and or a DISTINCT can slow performance. 
Also your distinct appeared to be in the wrong place, I am guessing the 
tblShopper.shopperid is unique so a DISTINCT there will not help you, however using it 
in the subquery makes sense since a sopper could have multiple orders. Truthfully 
though you could eliminate it from the subquery as well.
  
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Archives: http://www.houseoffusion.com/cf_lists/index.cfm?forumid=4
Subscription: 
http://www.houseoffusion.com/cf_lists/index.cfm?method=subscribe&forumid=4
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
This list and all House of Fusion resources hosted by CFHosting.com. The place for 
dependable ColdFusion Hosting.

                                Unsubscribe: 
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
                                

Reply via email to