Jump to content


Corporate Sponsors


Latest News: (loading..)

berthz

Member Since 28 Feb 2007
Online Last Active Today, 11:48
-----

Topics I've Started

Complex sql statement for product filter!?

24 November 2011, 13:12

I am trying to develop a filter for the product sort. I want to create the possibility for three selection:

1: Brand/manufacturer
2: Colour (its a product option)
3: Size (also a product option)

Customers see three dropdowns and with those filter the product in a category.

I managed to combine Brand with either Colour or Size but not the three filters together. The reason is that Colour and Size are both attributes from the same table. Therefore I need a little help with the following sql statement to have all three filters work together

$where = 'pa.products_id = p.products_id and (pa.options_values_id = \''.$var1.'\' where pa.options_id = \'1\') and pa.options_values_id = \''.$var2.'\' where pa.options_id = \'2\')';

The $var1 and $var2 work I just need to know how to double select on pa.options_values_id. So first of all $var1 corresponds with pa.options_values_id=1 and $var2 corresponds with pa.options_values_id=2. My where statement doesnt work because it involves more than one 'where' but how do I get this to work?

Thanks in advance.