MySQL server has gone awaySELECT DISTINCT e.subCat, sc.description, e.sortOrder
FROM rcdisco.subCatsExtras e
LEFT JOIN rcdisco.subCats sc ON e.subCat=sc.code
LEFT JOIN rcdisco.stockmaster s ON e.subCat=s.subCat
WHERE e.mainCat='P06'
AND s.showPublic LIKE '%YES%' AND sc.description IS NOT NULL
ORDER BY e.sortOrder, sc.sortOrder, sc.description