如何在asp.net TableAdapter中使用temptable使用的sqlquery [英] How to use temptable used sqlquery in asp.net TableAdapter
本文介绍了如何在asp.net TableAdapter中使用temptable使用的sqlquery的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
喜欢sql查询::
选择 A. * 进入#temp1 来自(选择
A.field
,B.field
,C.field
来自 tableA A
inner join tableB B
on A.field = B.field
inner join TableC C
on B.field = C.field
其中 A.field = 11
) as A
选择 B. * 进入#temp2 来自(选择
P.field
,Q.field
,R.field
来自 tableP P
内部 join tableQ Q
on P.field = Q.field
inner join TableR R
on Q.field = R.field
其中 P.field = 11
) as B
SELECT a。*
FROM #temp1 a
完整 外部 JOIN #temp2 b ON (a.field1 = b.field1
和 a.field2 = b.field2
)
WHERE b.field1 null 或 b.field2 null
解决方案
如果您的查询是这样的,我认为您不需要临时表。只需尝试:
选择 A. *
来自(选择 A.field
,B.field
,C.field
from tableA A
inner join tableB B A.field = B.field
inner join TableC C B.field = C.field
其中 A.field = 11 ) as A
您可以使用的更简化的版本是
选择
A.field
,B.field
,C.field
来自 tableA A
inner join tableB B
on A .field = B.field
inner join TableC C
上的code-keyword> B.field = C.field
其中 A.field = 11 跨度>
like sql query ::
Select A.* Into #temp1 from(select
A.field
,B.field
,C.field
from tableA A
inner join tableB B
on A.field=B.field
inner join TableC C
on B.field=C.field
where A.field= 11
) as A
Select B.* Into #temp2 from(select
P.field
,Q.field
,R.field
from tableP P
inner join tableQ Q
on P.field=Q.field
inner join TableR R
on Q.field=R.field
where P.field= 11
) as B
SELECT a.*
FROM #temp1 a
Full outer JOIN #temp2 b ON (a.field1 = b.field1
and a.field2 = b.field2
)
WHERE b.field1 is null or b.field2 is null
解决方案
If your query is like that, in my opinion you don't need the temp table. Simply try:
select A.* from(select A.field ,B.field ,C.field from tableA A inner join tableB B on A.field=B.field inner join TableC C on B.field=C.field where A.field= 11) as A
A more simplified version that you can use is
select A.field ,B.field ,C.field from tableA A inner join tableB B on A.field=B.field inner join TableC C on B.field=C.field where A.field= 11
这篇关于如何在asp.net TableAdapter中使用temptable使用的sqlquery的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文