学习。 exists是说在 Dictionary 对象中是否存在 in是指在这里面。如:select * from students where ID in(1,2,4);查询ID号在in里面的记录。
liuyi8903(甜脆夹心) 呵呵.第二个快! 第二个是直接用常量查. 而第一条却要进行一个全表扫描.第一条你可以改成 select * from a where exists (select b.cola from b where b.cola=a.cola); 第一条为什么不写成 select a.* from a,b where b.cola=a.cola;
exists是说在 Dictionary 对象中是否存在
in是指在这里面。如:select * from students where ID in(1,2,4);查询ID号在in里面的记录。
呵呵.第二个快!
第二个是直接用常量查.
而第一条却要进行一个全表扫描.第一条你可以改成
select * from a where exists (select b.cola from b where b.cola=a.cola);
第一条为什么不写成
select a.* from a,b where b.cola=a.cola;
这和常量的集合('a','b','c')相比,速度谁快,不用讲了吧。
需要先从b表获得结果集,再处理,select * from a where a.cola in (value1,value2,...);
结果集已经给定了,不需要准备数据过程。