MySQL中的树型结构

时间:2018-07-17 07:33:57

标签: mysql

我的第一个查询 wono=636363123;

select p1.P3_WOParentWONo,p1.P3_WOTypeId,p2.P3_WOType as childNode from 
p3_womaster p1 join p3_wotype p2 on p1.P3_WOTypeId=p2.P3_WOTypeId where p1.p3_wono=636363123;

结果:

 P3_WOParentWONo,         P3_WOTypeId, childNode
'66666666666666666666666666', '1', 'AWO'

我的第二个查询 P3_WOParentWONo=66666666666666666666666666;

select p1.P3_WOParentWONo,p1.P3_WOTypeId,p2.P3_WOType as ParentNode 
from p3_womaster p1 join p3_wotype p2 on p1.P3_WOTypeId=p2.P3_WOTypeId where p1.p3_wono=66666666666666666666666666;

结果

P3_WOParentWONo     P3_WOTypeId     ParentNode
                      2                    PWO

我可以将查询返回为表树类型结构吗?

对于wono = 636363123,我必须从p3_womaster中找到P3_WOParentWONo,然后再次传递P3_WOParentWONo来查找详细信息

0 个答案:

没有答案
相关问题