Filters: and productstatus != 0 and exists (select * from productproductcats where productproductcats.productid=products.productid and productcatid=1) and not exists (select * from productproductcats where productproductcats.productid=products.productid and productcatid='17')