还是先
select name,no
into #c
from table
where name='hello'再
select #c.name,b.number
from #c,table2 as b
where #c.no=b.no这样效率会更高吗? 这样写可以吗?
select name,no
into #c
from table
where name='hello'再
select #c.name,b.number
from #c,table2 as b
where #c.no=b.no这样效率会更高吗? 这样写可以吗?
会自动优化,如果table1.no,table2.no都有索引,先连接后筛选。
如果table1.no,table2.no没有索引,table1.name有索引,先筛选后连接。
其它情况很难说,但是会自动优化。
select a.name,b.number
from table as a ,table2 as b
where a.name='hello' and a.no=b.no