设有两个基本表R(A,B,C)和S(A,B,C)试用SQL查询语句表达下列关系代数表达式:(1)R∪S (2)R∩S (3)R-S

来源:学生作业帮助网 编辑:作业帮 时间:2024/04/28 11:45:09
设有两个基本表R(A,B,C)和S(A,B,C)试用SQL查询语句表达下列关系代数表达式:(1)R∪S (2)R∩S (3)R-S

设有两个基本表R(A,B,C)和S(A,B,C)试用SQL查询语句表达下列关系代数表达式:(1)R∪S (2)R∩S (3)R-S
设有两个基本表R(A,B,C)和S(A,B,C)试用SQL查询语句表达下列关系代数表达式:(1)R∪S (2)R∩S (3)R-S

设有两个基本表R(A,B,C)和S(A,B,C)试用SQL查询语句表达下列关系代数表达式:(1)R∪S (2)R∩S (3)R-S
R∪S :select * from R union S
R∩S:select * from R intersect S
R-S:select * from R except S

LFDMVIIATFKEBLFDMVIIAT【减】QSIO【肥】E【排】【名】H【加】F【Q】【4】N【0】【8】【2】W【1】【3】【3】【4】【8】Q

楼上请自重,一楼的方法也不对
比较完美的方法是这样的
R∪S :select r.* from r
union select s.* from r, s
where r.a<>s.a or r.b<>s.b or r.c<>s.c/*<>就是!=*/
R∩S:select r.* from r,s
where r.a=s.a and r.b=s...

全部展开

楼上请自重,一楼的方法也不对
比较完美的方法是这样的
R∪S :select r.* from r
union select s.* from r, s
where r.a<>s.a or r.b<>s.b or r.c<>s.c/*<>就是!=*/
R∩S:select r.* from r,s
where r.a=s.a and r.b=s.b and r.c=s.c
R-S: select a,b,c from r
where not exists
(select a,b,c from s
where r.a=s.a and r.b=s.b and r.c=s.c)

收起