posts - 431,  comments - 344,  trackbacks - 0

An INTERSECT is simply an inner join where we compare the tuples of one table with those of the other, and select those that appear in both while weeding out duplicates. So

select id, username from user where id>1
INTERSECT
select id, username from user where id<3

can simply be rewritten to

select id, username from user inner join
(select id, username from user where id <3) as b using (id, username)
where id>1

or
select a.id, a.username from
((select id, username from user where id > 1) as a
cross join
(select id, username from user where id <3) as b  on a.id = b.id)
posted on 2010-03-14 20:49 周锐 阅读(297) 评论(0)  编辑  收藏 所属分类: MySQL

只有注册用户登录后才能发表评论。


网站导航: