产品ID 零件ID
001 002
002 003
003 004
004 005如何由004查找到产品001的信息?急求该算法!
001 002
002 003
003 004
004 005如何由004查找到产品001的信息?急求该算法!
解决方案 »
- 遍历dataGridView排除不符合条件的信息
- can't read microsoft solution
- SQL语句取数据库的值
- ListBox的数据绑定问题 - 高手们快来啊
- 如何用 DataTable.Select()选出最大的Id?
- 有没有.net方面的群发的软件,主要是监控数据库,可以多线程,其实就是用.net做一个群发短信的软件!
- 一个很菜的问题,请不要笑
- WinForm中如何达到主从表显示效果?
- 哪位大侠推荐个C#程序中好用的OCR组件
- 我买了一本C#入门经典的书,想到www.wrox.com上注册一下,到底我的书的ISBN号是什么?
- innosetup 使程序后台默认安装?
- request.getresponse出现404页面不存在错误
declare @s nvarchar(50)
declare @result nvarchar(50)
set @s='004'
while (exists(select 1 from 表 where [零件ID] = @s))
begin
select @result = [产品ID] from 表 where [零件ID] = @s
set @s=@result
end
select @result
insert into #temp
select '001','002' union all
select '002','003' union all
select '003','004' union all
select '004','005' union all
select '005','006'declare @productid varchar(20)
set @productid='004'
;with cte as(
select productid,partsid from #temp where productid=@productid union all
select t.* from cte c inner join #temp t on t.partsid=c.productid
)
select top 1 * from cte order by productid
/*
001 002
*/
Class Product{
String ProductID{get;set;}
String PartID{get;set;}
Public Product GetPart()
{
//根据PartID查询出 新的Product 并返回,如果没有的话返回空
}
}
用法 Product.GetPart().GetPart()....
遍历 直至PartID为空 就可以把所有的 信息查出来.