2006 : MySQL server has gone away

error file : /shop/list.php

select a.* , case when b.catecode_2depth is null then 'N' else 'Y' end cate_2depth_yn , ifnull( b.catecode_2depth , '' ) as catecode_2depth , ifnull( b.upcate , '' ) as upcate_2depth , ifnull( b.catename , '' ) as catename_2depth , ifnull( b.caterank , '' ) as caterank_2depth , ifnull( b.catehide , '' ) as catehide_2depth , ifnull(b.ca_id_cnt, 0) AS ca_id_cnt_2depth, ifnull(b.ca_id_cnt2, 0) AS ca_id_cnt2_2depth, ifnull(b.ca_id_cnt3, 0) AS ca_id_cnt3_2depth, case when c.catecode_3depth is null then 'N' else 'Y' end cate_3depth_yn , ifnull( c.catecode_3depth , '' ) as catecode_3depth , ifnull( c.upcate , '' ) as upcate_3depth , ifnull( c.catename , '' ) as catename_3depth , ifnull( c.caterank , '' ) as caterank_3depth , ifnull( c.catehide , '' ) as catehide_3depth , ifnull( c.ca_id_cnt , 0 ) as ca_id_cnt_3depth , ifnull( c.ca_id_cnt2 , 0 ) as ca_id_cnt2_3depth , ifnull( c.ca_id_cnt3 , 0 ) as ca_id_cnt3_3depth from( /* 1depth 검사 */ SELECT DISTINCT x.*, sum(CASE WHEN y.ca_id != '' THEN 1 ELSE 0 END) AS depth1_cnt_1, sum(CASE WHEN y.ca_id2 != '' THEN 1 ELSE 0 END) AS depth1_cnt_2, sum(CASE WHEN y.ca_id2 != '' THEN 1 ELSE 0 END) AS depth1_cnt_3 FROM (SELECT catecode, upcate, catename, caterank, cateuse, catehide FROM shop_category WHERE length(catecode) = '3' AND cateuse = '0' AND find_in_set('admin', catehide) = '0') AS x LEFT JOIN (SELECT ca_id, ca_id2, ca_id3 FROM shop_goods WHERE NOT (ca_id = '' AND ca_id2 = '' AND ca_id3 = '') AND shop_state = '0' AND isopen IN ('1', '2') GROUP BY ca_id, ca_id2, ca_id3) AS y ON x.catecode = left(y.ca_id, 3) OR x.catecode = left(y.ca_id, 6) OR x.catecode = left(y.ca_id, 9) GROUP BY catecode, catename ) as a left join ( /* 2depth 검사 */ SELECT xx.*, sum(CASE WHEN yy.ca_id != '' THEN 1 ELSE 0 END) AS ca_id_cnt, sum(CASE WHEN yy.ca_id2 != '' THEN 1 ELSE 0 END) AS ca_id_cnt2, sum(CASE WHEN yy.ca_id3 != '' THEN 1 ELSE 0 END) AS ca_id_cnt3 FROM (SELECT x.catecode, y.catecode AS catecode_2depth, y.upcate, y.catename, y.caterank, y.cateuse, y.catehide FROM (SELECT * FROM shop_category WHERE length(catecode) = '3' AND cateuse = '0' AND find_in_set('admin', catehide) = '0') AS x LEFT JOIN shop_category AS y ON x.catecode = y.upcate WHERE y.upcate <> '' AND y.cateuse = '0' AND find_in_set('admin', y.catehide) = '0') AS xx LEFT JOIN (SELECT ca_id, ca_id2, ca_id3 FROM shop_goods WHERE NOT (ca_id = '' AND ca_id2 = '' AND ca_id3 = '') AND shop_state = '0' AND isopen IN ('1', '2') GROUP BY ca_id, ca_id2, ca_id3) AS yy ON yy.ca_id LIKE concat(catecode_2depth, '%') OR yy.ca_id2 LIKE concat(catecode_2depth, '%') OR yy.ca_id3 LIKE concat(catecode_2depth, '%') GROUP BY catecode_2depth ) as b on a.catecode = b.catecode left join( /* 3depth 검사 */ SELECT xx.*, sum(CASE WHEN yy.ca_id != '' THEN 1 ELSE 0 END) AS ca_id_cnt, sum(CASE WHEN yy.ca_id2 != '' THEN 1 ELSE 0 END) AS ca_id_cnt2, sum(CASE WHEN yy.ca_id3 != '' THEN 1 ELSE 0 END) AS ca_id_cnt3 FROM (SELECT x.catecode, y.catecode AS catecode_3depth, y.upcate, y.catename, y.caterank, y.cateuse, y.catehide FROM (SELECT * FROM shop_category WHERE length(catecode) = '6' AND cateuse = '0' AND find_in_set('admin', catehide) = '0') AS x LEFT JOIN shop_category AS y ON x.catecode = y.upcate WHERE y.upcate <> '' AND y.cateuse = '0' AND find_in_set('admin', y.catehide) = '0') AS xx LEFT JOIN (SELECT ca_id, ca_id2, ca_id3 FROM shop_goods WHERE NOT (ca_id = '' AND ca_id2 = '' AND ca_id3 = '') AND shop_state = '0' AND isopen IN ('1', '2') GROUP BY ca_id, ca_id2, ca_id3) AS yy ON yy.ca_id LIKE concat(catecode_3depth, '%') OR yy.ca_id2 LIKE concat(catecode_3depth, '%') OR yy.ca_id3 LIKE concat(catecode_3depth, '%') GROUP BY catecode_3depth ) as c on b.catecode_2depth = c.catecode order by a.caterank , b.caterank , c.caterank;