Let's say you have the following table: items(item_id, item_parent) ... and it is a self-referencing table as item_parent refers to item_id.
What MySQL supported SQL query would you use to SELECT each item in the table along with a boolean value that indicates whether that item is a parent / has other items referencing to it?
If you have the following data in the table:
item_id item_parent
----------- -----------
1 0
2 0
3 2
4 2
5 3
... the query should be able to retrieve the following set of objects:
{"item_id":1,"is_parent":0}
{"item_id":2,"is_parent":1}
{"item_id":3,"is_parent":1}
{"item_id":4,"is_parent":0}
{"item_id":5,"is_parent":0}