Closed (won't fix)
Project:
Category
Version:
master
Component:
Code
Priority:
Minor
Category:
Feature request
Assigned:
Reporter:
Created:
30 Oct 2006 at 23:30 UTC
Updated:
13 May 2011 at 20:37 UTC
First, the trick:
SELECT DISTINCT c.*,n.title
FROM (
category c
INNER JOIN node n
ON c.cid=n.nid
INNER JOIN category_hierarchy p2
ON c.cid=p2.cid
LEFT OUTER JOIN category_hierarchy p1
ON p1.cid = p2.parent
)
WHERE p2.parent <> 0
AND p1.cid IS NULL;
This code implements a set difference between (all categories in the hierarchy) and (categories in the hierarchy with parents that exist in the hierarchy) to get (categories in the hierarchy with parents that do not exist in the hierarchy.)
This code will not find completely uncategorized cats (as opposed to normal orphans, which are still categorized, but with invalid parents), but it should be possible to do this with another query that finds the set of categories that don't have any mention in the category_hierarchy table.
--Brandon
Comments
Comment #1
bdragon commentedComment #2
bdragon commented