如何通过VB 将datatable中的数据不重复添加进listbox?
3个回答
展开全部
必须有唯一标识列才能过滤重复,下面给你个思路:
生成唯一id列:
select id=identity(1,1),bianhao、name、jiage、chandi、shuliang into #tmp_tb from 表1
查询显示name不重复的所有数据:
select * from #tmp_tb t1 where not exists (select 1 from #tmp_tb t2 where t2.name=t1.name and t2.id<t1.id)
bianhao列为唯一标示列,显示大的小的都可以
--------------------
那直接查就可以了:
select * from kucun t1 where not exists (select 1 from kucun t2 where t2.name=t1.name and t2.bianhao<t1.bianhao)
生成唯一id列:
select id=identity(1,1),bianhao、name、jiage、chandi、shuliang into #tmp_tb from 表1
查询显示name不重复的所有数据:
select * from #tmp_tb t1 where not exists (select 1 from #tmp_tb t2 where t2.name=t1.name and t2.id<t1.id)
bianhao列为唯一标示列,显示大的小的都可以
--------------------
那直接查就可以了:
select * from kucun t1 where not exists (select 1 from kucun t2 where t2.name=t1.name and t2.bianhao<t1.bianhao)
参考资料: http://zhidao.baidu.com/question/165081757.html
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询