select * from table1, table2 where table1.column1 = table2.cloumn1。 我听别人说这样的查询语句查询效率不高呀!!有没有别的语句替代,达到同样的效果。楼主要的答案是不是这个: select * from table1 as t1 join table2 as t2 on(t1.column1=t2.column1)
等值连接用join...using,非等值连接用join...on select * from table1 as t1 join table2 as t2 on(t1.column1=t2.column1); select * from table1 join table2 using (column1);
先不管* 后面那个where还可以优化吗 用inner也会慢吧
select * from table1 as t1 join table2 as t2 on(t1.column1=t2.column1); 这个sql语句是不是会比较快点吧???
select * from table1, table2 where table1.column1 = table2.cloumn1 这已经是最快的了,使用in 或 on 左连接 由连接 都没有这个快,要是在oracl里,它有个查询优化器,会优化为最优的那种。如果两个表数据大小不一样的话,表小的应该放在后面,因为执行sql时,他是从后面开始执行的。
如果想取全项目的话,我自己试了一下,下面的这个方法最快
select *
from table1 t1, table t2
where t1.column1 = t2.column1;
select * from table1 where table1.column1 in
(select table2.column1 from table2)
我听别人说这样的查询语句查询效率不高呀!!有没有别的语句替代,达到同样的效果。楼主要的答案是不是这个:
select * from table1 as t1 join table2 as t2 on(t1.column1=t2.column1)
select * from table1 as t1 join table2 as t2 on(t1.column1=t2.column1);
select * from table1 join table2 using (column1);
后面那个where还可以优化吗
用inner也会慢吧
这个sql语句是不是会比较快点吧???
这已经是最快的了,使用in 或 on 左连接 由连接 都没有这个快,要是在oracl里,它有个查询优化器,会优化为最优的那种。如果两个表数据大小不一样的话,表小的应该放在后面,因为执行sql时,他是从后面开始执行的。