MySQL server has gone away SQL query : select count(*) from SS_products AS pt LEFT JOIN SS_product_options_values AS po ON pt.productID=po.productID and po.optionID=36 where enabled=1 AND categoryID=9821 OR enabled=1 AND categoryID=8797 OR enabled=1 AND categoryID=9873 OR enabled=1 AND categoryID=9569 OR enabled=1 AND categoryID=8796 OR enabled=1 AND categoryID=8799 OR enabled=1 AND categoryID=8800 OR enabled=1 AND categoryID=8801 OR enabled=1 AND categoryID=8802 OR enabled=1 AND categoryID=9815 OR enabled=1 AND categoryID=8804 OR enabled=1 AND categoryID=8803 OR enabled=1 AND categoryID=8805 OR enabled=1 AND categoryID=8806 OR enabled=1 AND categoryID=8807 OR enabled=1 AND categoryID=9863 OR enabled=1 AND categoryID=8808 OR enabled=1 AND categoryID=8809 OR enabled=1 AND categoryID=8810 OR enabled=1 AND categoryID=8811 OR enabled=1 AND categoryID=6611 order by in_stock DESC, Price, name