当前位置: 代码迷 >> .NET Framework >> ASP.NET在一个表里面有两个字段诀别保存代表上下集的两个子段,怎样筛选出没有子集的数据
  详细解决方案

ASP.NET在一个表里面有两个字段诀别保存代表上下集的两个子段,怎样筛选出没有子集的数据

热度:162   发布时间:2016-05-01 23:23:46.0
ASP.NET在一个表里面有两个字段分别保存代表上下集的两个子段,怎样筛选出没有子集的数据
如题,在一个表中有十几条数据,该表中有一个字段Code,ParentCode, Code 代表他自身,ParentCode代表他的父集,怎样查询该条数据没有子集,求教大神!在线等,谢谢!!

------解决思路----------------------
引用:
select * from table
where code not in (select distinct(parentcode) from table order by parentcode)


select * from table
where code not in (select distinct(parentcode) from table group by parentcode) 
  相关解决方案