mysql 相同表求解统一字段不同内容的交集

  1. SELECT id, bid, name, title, publisher FROM A where publisher in (select publisher from B group by B.publisher)
 

或者

  1. SELECT id, bid, name, title, publisher FROM A where exists (select publisher from B where B.publisher = A.publisher group by B.publisher)
 

用EXISTS应该效率更高,另外对查询条件字段publisher建立索引。

原文地址:https://www.cnblogs.com/panpeng666/p/4505461.html