# 608. Tree Node ###### tags: `SQL` `medium` https://leetcode.com/problems/tree-node/description/    將樹放進SQL的題目 題目要求將樹的type寫上去 root 根 代表為null inner 中間 不為根也不為葉 代表有父及子 也就是p_id裡有的 leaf 葉 只有父沒有子 所以解題方式就是判斷 pid為null肯定根 id不再pid的又不是null 那就是leaf 而剩下的就為inner 這次使用了case when SQL的判斷 而判斷pid也可直接判斷inner 因為pid裡有的就是inner 所以else inner或leaf都行 解題如下 
×
Sign in
Email
Password
Forgot password
or
By clicking below, you agree to our
terms of service
.
Sign in via Facebook
Sign in via Twitter
Sign in via GitHub
Sign in via Dropbox
Sign in with Wallet
Wallet (
)
Connect another wallet
New to HackMD?
Sign up