I've a two tables.
one is products
the others are a list of attributes for the products.
Each product can have several attributes.
My statement at the minute is looking to find all product who have a certain combination of attributes.
So I have
SELECT ProductID, Productname from Products WHERE ProductID IN ((SELECT ProductID FROM Filter WHERE ProductID = Products.ProductID AND FilterName = 'No Brake')) AND ProductID IN ((SELECT ProductID FROM Filters WHERE ProductID = Products.ProductID AND FilterName = 'None'))
I know this works, but it's very inefficient and I'm looking to re-work it to get it much better.
I know both the multiple IN statements (and perhaps the IN statement in general) could be improved but I'm looking for suggestions as the best way to do this.
It should be noted that this statement is dynamic and dependant upon user input, that statement and the number of attributes to check for could be many more or less.
Hope anyone can offer me a guiding light in getting this better!
Thank for any replies