MySQL Solution
\nselect id,\n    case\n    when p_id is null then \'Root\'\n    when id in (select p_id from tree) then \'Inner\'\n    else \'Leaf\' end as Type\nfrom Tree\n
```\nselect id,\n    case\n    when p_id is null then \'Root\'\n    when id in (select p_id from tree) then \'Inner\'\n    else \'Leaf\' end as Type\nfrom Tree\n```
['MySQL']