现在两个表:
表A:name count
aa 1
bb 1
cc 0
dd 1
ee 0表B:name ...
aa ...
qq ...
xx ...
ee ...现在是要将表A中count=1的name,又出现在表B中的name找出来
结果应该是
name
aa
ee我这样写的:select B.name from B (select name from A where count=1) T where B.name=T.name;但由于我的数据量很大,这样运行起来速度很慢,请问有没有效率更高的sql语句
表A:name count
aa 1
bb 1
cc 0
dd 1
ee 0表B:name ...
aa ...
qq ...
xx ...
ee ...现在是要将表A中count=1的name,又出现在表B中的name找出来
结果应该是
name
aa
ee我这样写的:select B.name from B (select name from A where count=1) T where B.name=T.name;但由于我的数据量很大,这样运行起来速度很慢,请问有没有效率更高的sql语句
from a ,b
where a.coount=1 and a.name=b.name创建A(COUNT)索引,创建 B(NAME)索引。
再加上外面select就可想而知,你sql效率了
你这样试试呢
select a.name from A a join B b on a.name = b.name where a.count=1实现不行 就建立索引吧