我有两个表,aaa和bbb。
现在,我想查询bbb里的字段date>123232432的id,在aaa里的同样ID的password记录数,我这样写SQL:select t1.id t1.password from aaa as t1,bbb as t2 where t2.password<123232432;为什么查询后机器就死了,是不是写错了?记录也不多就80000条左右。请高手指教,谢谢!
现在,我想查询bbb里的字段date>123232432的id,在aaa里的同样ID的password记录数,我这样写SQL:select t1.id t1.password from aaa as t1,bbb as t2 where t2.password<123232432;为什么查询后机器就死了,是不是写错了?记录也不多就80000条左右。请高手指教,谢谢!
现在,我想查询bbb里的字段date>123232432的id,在aaa里的同样ID的password记录数,我这样写SQL:select t1.id t1.password from aaa as t1,bbb as t2 where t2.password<123232432;为什么查询后机器就死了,是不是写错了?记录也不多就80000条左右。请高手指教,谢谢!
select * from aaa where id in (select id from bbb where date>123232432)
2、你原来的PASSWORD字段有没有加索引?
推荐
select t1.id t1.password from aaa as t1,bbb as t2 where t2.password<123232432 and t1.id = t2.id;