Home
Help
Register
Log in

Search

 
   Active Threads  

You are here: Home > LLBLGen Pro > LLBLGen Pro Runtime Framework> A puzzle .. anyone?
 

Pages: 1
LLBLGen Pro Runtime Framework
A puzzle .. anyone?
Page:1/1 

  Print all messages in this thread  
Poster Message
Pablo
User



Location:
Sneek
Joined on:
21-Mar-2005 01:17:52
Posted:
81 posts
# Posted on: 14-Jan-2010 22:05:25.  
Hello,
Can anyone have a look a the following ...

I have 2 entities: Customers and Orders
Customers and Orders are related via a CustomerId.

I want to select ALL customers,
EXCEPT those customers that have previously ordered a product with ProductId=x

I've tried something like:
select customers Where Order.ProductId != x

This seems to work, however, the customers who havent got any order yet, are not included, and I need those too!


Any help is appreciated!
Paul
  Top
MTrinder
User



Location:
London by day, Milton Keynes by night.
Joined on:
08-Oct-2008 17:55:47
Posted:
1461 posts
# Posted on: 14-Jan-2010 23:59:41.  
SELECT * FROM Customer
WHERE CustomerId NOT IN
(SELECT CustomerId FROM Order WHERE ProductId=x)

ie - get all of the customer ids that HAVE ordered product x, and then all of the customers that are not in this list - so this should get the ones that have not ordered anything yet as well.

All you have to do now is translate this to an LLBLGen or LINQ query - "left as an excercise for the reader" Regular Smiley



Matt


  Top
Pablo
User



Location:
Sneek
Joined on:
21-Mar-2005 01:17:52
Posted:
81 posts
# Posted on: 15-Jan-2010 13:40:47.  
Matt,
thanx a million, I got stuck into thinking it was not possible, but hey, that cannot be possible....right?
The solution is painfully simple.
Many thanks ...
Paul
  Top
Pages: 1  


Powered by HnD ©2002-2007 Solutions Design
HnD uses LLBLGen Pro

Version: 2.1.12172008 Final.