Re: Curious SQL question
Date: 3 Jan 2007 13:53:53 -0800
Message-ID: <1167861233.463247.232370_at_s34g2000cwa.googlegroups.com>
> Products (ID, Name) > Orders (Customer_ID, Product_ID) > > How can I find out what products, each customer DIDN'T bought?
Below is an alternate partial solution using dbd. John orders shampoo
and soap. Mary orders soap and bread. No one orders wine. Queries
returns what products John, Mary and any person did not order.
(new 'shampoo 'product)
(new 'john 'person)
(new 'soap 'product)
(new 'bread 'product)
(new 'wine 'product)
(set john order shampoo)
(new 'mary 'person)
(set mary order soap)
(set mary order bread)
(; Get products not ordered by john)
(; Gets bread and wine)
(!= (get product instance *)
(get john order *))
(; Get products not ordered by mary)
(; Gets shampoo and wine)
(!= (get product instance *)
(get mary order *))
(; Get products not ordered by any person)
(; Gets wine)
(!= (get product instance *)
(get (get person instance *) order *)) Received on Wed Jan 03 2007 - 22:53:53 CET