Home > database >  Ask: a SQL query ID, NAME, ID, father father NAME, whether can you?
Ask: a SQL query ID, NAME, ID, father father NAME, whether can you?

Time:10-24

How to use a SQL query ID, NAME, ID, father father NAME;

If it is the parent node ParentID default to 1, the father NAME is empty

Table structure is: the ID ParentID TheName




CodePudding user response:

 Select * from table name a LEFT JOIN table name ON Amy polumbo arentID b=b.I D 


CodePudding user response:

Select ID, TheName, ParentID, (select * from table NAME as a where Anderson, d=p. arentID) as the parent NAME from the NAME of the table as b so great