get all parents with it's child from single table
Hi, I am trying to use LEFT JOIN to get Parent data first then it's child with — before it.
I have like this table
+----+-------+------+--------+
| id | name | count| parent |
+----+-------+------+--------+
| 1 | parent| 2 | 0 |
+----+-------+------+--------+
| 2 | child | 1 | 1 |
+----+-------+------+--------+
|....| ..... | .... | ..... |
+----+-------+------+--------+
How can I get all parents (after parent then — and it's child) then all remaining parents etc. etc.
I tried to use
SELECT table.id, table.name, table.count as child_data FROM table
LEFT JOIN table AS parent_data ON child_data.parent = parent_data.Id;
But I am getting an error, I know I am doing something wrong with this, please help me to find my mistakes.
Subject
Written By
Posted
get all parents with it's child from single table
February 05, 2018 02:38PM
February 05, 2018 04:05PM
February 05, 2018 07:47PM
Sorry, you can't reply to this topic. It has been closed.
Content reproduced on this site is the property of the respective copyright holders.
It is not reviewed in advance by Oracle and does not necessarily represent the opinion
of Oracle or any other party.