Multiple ways heres one:

SELECT CustID
FROM    Customers
WHERE CustID NOT IN (Select CustID From Orders)


Adam 


On Tue, 30 Nov 2004 12:01:30 -0500, Che Vilnonis <[EMAIL PROTECTED]> wrote:
> 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:185684
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

Reply via email to