I have a platforms
table that has id
, name
and parent_id
and other columns.
Is it possible to write a query that selects all platforms
from the table, and if it has a parent_id
which is not 0
, an extra column gets added which has the parent_name
?
Like:
id name parent_id
2 pl1 0
3 pl2 0
4 pl3 2
And the desired query would yield:
id name parent_id parent_name
2 pl1 0
3 pl2 0
4 pl3 2 pl1