Cleaner SQL CTE than the current one
问题 Currently I use the following CTE to grab a category and any category below it: WITH RECURSIVE tree AS ( SELECT * FROM ( SELECT categoryId, categoryName, categoryParentId, categoryDescr, categoryType, categoryDC, categoryLedgerId, 1 as categoryDepth FROM tbl_categories WHERE categoryId = '.$categoryId.' UNION SELECT categoryId, categoryName, categoryParentId, categoryDescr, categoryType, categoryDC, categoryLedgerId, 1 as categoryDepth FROM tbl_categories_custom WHERE categoryId = '.