seva2
Партнер PHPClub.ru
Запрос с двумя условиям по опциям?
Так не работает!
А так работает:
Подскажите что в первом запросе не так?
PHP:
$get_prod=mysql_query("select pd.products_name, pc.products_id, pc.categories_id from products as p, products_to_categories as pc, products_description as pd, products_properties as pp where p.products_id=pc.products_id and pc.products_id=pd.products_id and p.products_quantity>'0' and pc.categories_id='17' and pp.products_id=p.products_id and (pp.options_id='141' and pp.options_values_id='".get_zn_opcii('141', $get_prod_to_cat_rows['products_id'])."' and pp.options_id='142' and pp.options_values_id='".get_zn_opcii('142', $get_prod_to_cat_rows['products_id'])."') group by p.products_id having count(distinct pp.options_id) = 2");
А так работает:
PHP:
$get_prod=mysql_query("select pd.products_name, pc.products_id, pc.categories_id from products as p, products_to_categories as pc, products_description as pd, products_properties as pp where p.products_id=pc.products_id and pc.products_id=pd.products_id and p.products_quantity>'0' and pc.categories_id='17' and pp.products_id=p.products_id and (pp.options_id='141' and pp.options_values_id='".get_zn_opcii('141', $get_prod_to_cat_rows['products_id'])."') group by p.products_id having count(distinct pp.options_id) = 1");