I'm trying to return the father ID of my table (MySQL), this is the return:
ID NOME PARENT_ID
1 Project (null)
2 Sub 1
3 Sub-Sub 2
4 Sub-Sub-Sub 3
I need this:
ID NOME PARENT_ID FATHER_ID
1 Project (null) (null)
2 Sub 1 1
3 Sub-Sub 2 1
4 Sub-Sub-Sub 3 1
Here is the fiddle
I had to use a function like this (link SO PT-BR):
SQL Fiddle.
SQL Fiddle2.