mysql 相同表求解统一字段不同内容的交集
- SELECT id, bid, name, title, publisher FROM A where publisher in (select publisher from B group by B.publisher)
或者
- 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建立索引。
posted on 2015-05-15 11:22 panpeng666 阅读(468) 评论(0) 编辑 收藏 举报