有A、B、C三个表,我想实现:先把A和B取合集,再将这个合集与C表取交集,也就是实现A∪B∩C,该怎么用SQL语句写呢?
首先感谢liaoxw624的回答,我试了一下
select x1.* from
(
(SELECT id FROM A)
UNION
(SELECT id FROM B)
)x1
INNER JOIN
C AS t1 ON t1.id=x1.id
提示错误信息:Every derived table must have its own alias
于是,我又试了一下这个:
select x2.* from
(
(
(SELECT id FROM A)
UNION
(SELECT id FROM B)
)x1
INNER JOIN
C AS t1 ON t1.id=x1.id
)x2
又提示说最后两行有语法错误,该怎么办呢?
UYOU
相关分类