How about this? Select CustID from customers where custID not in (select custid from orders)
-dov -----Original Message----- From: Che Vilnonis [mailto:[EMAIL PROTECTED] Sent: Tuesday, November 30, 2004 12:01 PM To: CF-Talk Subject: SQL Query question. Please help... Say I have two simple queries: <cfquery name="getCustsFromCusts" datasource="#DSN#"> SELECT CustID FROM Customers </cfquery> [and that query returns 700 records.] <cfquery name="getCustsFromOrders" datasource="#DSN#"> SELECT CustID FROM Orders </cfquery> [and that query returns 500 records.] The first query gets all Customer IDs. The second query gets all Csutomer IDs that have placed orders. Is there some way in SQL, to combine these two queries into one and return only the Customer IDs that are in the 'Customers' table that ARE NOT in the 'Orders' table. Using this example, 200 records would be returned. Any help would be appreciated. Che ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Special thanks to the CF Community Suite Silver Sponsor - CFDynamics http://www.cfdynamics.com Message: http://www.houseoffusion.com/lists.cfm/link=i:4:185685 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54

