SELECT A.*,case A.cat_order when 0 then 999 else A.cat_order end as cat_orders,B.sCort from bb_product_category A ,bb_product_category B where A.user_id = '749' and A.com_id = '861' and substring(B.sCort,1,length(A.sCort))=A.sCort and A.cat_state = 1 and A.cat_parentid = 3260 and A.cat_bbt_state <> 2 group by A.cat_id order by A.cat_orderLost connection to MySQL server during query