Lost connection to server during query SQL query : SELECT categoryID, name, brief_description, customers_rating, Price, in_stock, customer_votes, list_price, sp.productID, default_picture, sort_order, items_sold, enabled, product_code, description, shipping_freight FROM ss_products sp LEFT JOIN ss_product_options_values spov on (spov.productID = sp.productID) where enabled=1 AND categoryID=79 AND REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(REPLACE(spov.option_value, ' ', ''), '-', ''), '+', ''), '&', ''), '(', ''), ')', ''), 'Chengshan', ''), '@', ''), '*', ''), ',', ''), "'", "") in ('205','60','16') AND spov.optionID in (7,8,5) GROUP BY sp.productID HAVING COUNT(sp.productID) = 3 order by in_stock > 0 DESC, in_stock DESC