MySQL server has gone away SQL query : SELECT c.name, c.parent, p.name, p2.name, p.parent FROM SS_categories c left join SS_categories p on (p.categoryID=c.parent) left join SS_categories p2 on (p2.categoryID=p.parent) WHERE c.categoryID<>0 and c.categoryID<>1 and c.categoryID='6416'