For context, I'm pretty new to SQL.
I'm doing a Leetcode problem #608, don't want it solved for me, but here it is for reference:
https://leetcode.com/problems/tree-node/
The table has 2 columns:
id: int
p_id: int
I basically want to see for each id
value whether or not it exists in the p_id
column.
I tried the following to test this:
SELECT id NOT IN (p_id)
FROM tree
What I want is, using this input as reference, is an output of (1, 1, 0, 0, 0) Boolean values.
However, from what I currently UNDERSTAND, this doesn't work because the column p_id is not in a comma-separated list. Is there a way to convert a column into a comma separated list? Or is there another way to approach this to get my desired outcome?