我是SQL查询的新手。r1,r2是数据列表。
我想要实现r3 = r1 - (r1 - r2),而不需要相交。而且.是设定的操作。stuid是检查值为-。
我认为遵循SQL查询是可行的。
create table r3 as
select *
from r1;
create table r4 as
select *
from r1;
delete from r3
where r3.stuid in
(delete from r4
where r4.stuid = r2.stuid)
(我必须两次使用删除查询)
起作用了吗?
发布于 2016-12-01 13:37:08
你似乎想要两组之间的重叠。不如这样做:
select r1.*
from r1
where exists (select 1 from r2 where r2.stuid = r1.stuid);
如果您想要一张新桌子:
create table r3 as
select r1.*
from r1
where exists (select 1 from r2 where r2.stuid = r1.stuid);
https://stackoverflow.com/questions/40911909
复制相似问题