Multiple lookup to return a distinct value

Posts   
 
    
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 18-Jun-2008 22:12:23   

I've got a products table, and a features table, and I would like to do a search to find a product that matches a certain criteria.... and for this example the product MUST have all the features specified.

So I may have the following table (ProductFeatureProfile):

ProductID, FeatureID
1,100
1,101
1,102
2,100
2,101
2,103
3,102
3,104
3,106

What I would like to do is use LLBL go get me all the product where:

FeatureID = 100 AND FeatureID = 101 AND FeatureID = 102

Does that make sense? I hope so, I'm now on v2.5 rather than 2.0 mentioned in my footer.

Many thanks

Darren

daelmo avatar
daelmo
Support Team
Posts: 8245
Joined: 28-Nov-2005
# Posted on: 19-Jun-2008 07:25:59   

daz_oldham wrote:

So I may have the following table (ProductFeatureProfile):

ProductID, FeatureID
1,100
1,101
1,102
2,100
2,101
2,103
3,102
3,104
3,106

What I would like to do is use LLBL go get me all the product where:

FeatureID = 100 AND FeatureID = 101 AND FeatureID = 102

Does that make sense?

Hi Darren, I think that you need something like this:


WHERE 
     ProductID IN (SELECT ProductId FROM  ProductFeatureProfile WHERE FeatureID = 100) 
     ProductID IN (SELECT ProductId FROM  ProductFeatureProfile WHERE FeatureID = 101)
     ProductID IN (SELECT ProductId FROM  ProductFeatureProfile WHERE FeatureID = 102)

Please read this similar thread: http://llblgen.com/TinyForum/Messages.aspx?ThreadID=12879

David Elizondo | LLBLGen Support Team
daz_oldham avatar
daz_oldham
User
Posts: 62
Joined: 20-Jul-2007
# Posted on: 19-Jun-2008 18:21:32   

That looks exactly like what I need - I'll be working on this tomorrow so I will give it a try smile

Thanks very much

Darren