一个user表
一个product表
id
userid
product_name
如果想找到username='test' 的所有product的话 用
select * from product where userid in (select id from user where username='test')
这样的语句,可当数据量大的时候效率非常的底下那怎么样提高效率呢?
一个product表
id
userid
product_name
如果想找到username='test' 的所有product的话 用
select * from product where userid in (select id from user where username='test')
这样的语句,可当数据量大的时候效率非常的底下那怎么样提高效率呢?
from product a,user b
where a.userid = b.id and b.username='test'
from product a,user b
where a.userid = b.id and b.username='test'
select * from product where exists(select 1 from user where username='test')
速度怎么样,楼主自己测吧