MySQL: fast and simple
Upvote if you like the solution\n```\nSELECT id,\n\n    CASE \n        WHEN p_id IS NULL THEN \'Root\'\n        WHEN id IN (SELECT p_id FROM Tree)THEN \'Inner\'
Upvote if you like the solution\n```\nSELECT id,\n\n    CASE \n        WHEN p_id IS NULL THEN \'Root\'\n        WHEN id IN (SELECT p_id FROM Tree)THEN \'Inner\'\n        ELSE \'Leaf\'\n        END AS type\n FROM Tree\n\t\t
['MySQL']