in和exists的区别 select * from a where aid in (select aid from b) in是遍历内表,把内表的每一个元素依照外表上的索引,看外表中是否存在匹配的数据, select * from a where exists (select aid from b where b.aid = a.aid) exists是遍历外表,把外表的每一个元素依照内表的索引,看内表中是否有匹配的数据 in适合内表小,外表大、 exists适合内表大,外表小