select * from optionInfo a ,(********) b where a.OptionID=b.OptionID注:上面******** 是一个子查询。 返回一列 当select * 的时候没有问题, 不过我改成select a.*就会出现查询超时 大家看看有么有遇到这种情况? 或者知道是什么原因造成的
试试这个select a.* from optionInfo a left join (********) b on a.OptionID=b.OptionID
if object_id('tt') is not null drop table tt if object_id('tb') is not null drop table tb go Create table tt(id int,Num decimal(15,5)) Create table tb(id int,Num decimal(15,5),pID int) go insert into tt select 1,0 union all select 2,0 union all select 3,0 union all select 4,4 insert into tb select 1,0,1 union all select 2,0,1 union all select 3,0,1 union all select 4,4,1 go select a.* from tb a ,(select top 1 id from tt) b where a.pID= b.idselect * from tb a ,(select top 1 id from tt) b where a.pID= b.id--感觉没有区别啊
inner join (********) b
on a.OptionID=b.OptionID
應該不會出現樓主的情況,樓主選中語句查看執行計劃
left join (********) b
on a.OptionID=b.OptionID
if object_id('tt') is not null
drop table tt
if object_id('tb') is not null
drop table tb
go
Create table tt(id int,Num decimal(15,5))
Create table tb(id int,Num decimal(15,5),pID int)
go
insert into tt
select 1,0 union all
select 2,0 union all
select 3,0 union all
select 4,4
insert into tb
select 1,0,1 union all
select 2,0,1 union all
select 3,0,1 union all
select 4,4,1
go
select a.* from tb a ,(select top 1 id from tt) b
where a.pID= b.idselect * from tb a ,(select top 1 id from tt) b
where a.pID= b.id--感觉没有区别啊
我感觉 很多觉得不可能发生的事情 最终原因都是有些地方疏漏了