Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一张桌子:
Id | Name | ParentID
我想parentid用父记录选择不等于零的记录(父记录有parentid = 0,但某些父记录没有子记录我想跳过它们)
parentid
parentid = 0
试试这个:
SELECT child.Id, child.Name, child.ParentId, parent.Name as ParentName FROM your_table child JOIN your_table parent ON child.ParentId = parent.id;
检查这个:
select * from child c,parent p where c.ID=P.ParentID and c.ParentID !=0