Re: Curious SQL question

From: Lennart <Erik.Lennart.Jonsson_at_gmail.com>
Date: 3 Jan 2007 05:26:51 -0800
Message-ID: <1167830811.304895.265730_at_h40g2000cwb.googlegroups.com>


Guto wrote:
> Hi There!
> If I have two tables:
>
> Products
> -Product_ID
> -Product_Name
>
> and
>
> Orders
> -Customer_ID
> -Product_ID
>
>
> How can I find out what products, each customer DIDN'T bought?
>
> I tried lots of SQL sentences, but I can onlye get it solved, through a
> Stored Procedure.
>
>
> The obvius does not work:
>
> Select Customer_ID, Product_ID from Orders
> where Product_ID not in ( select Product_id from Products )
>
> Any Tips?

I assume you miss one relation here, namely Customer. I think this is what you are looking for:

(Customer x Product) - Orders

/Lennart Received on Wed Jan 03 2007 - 14:26:51 CET

Original text of this message