a
This commit is contained in:
45
Semester 2/SQL Hell pt4.txt
Normal file
45
Semester 2/SQL Hell pt4.txt
Normal file
@@ -0,0 +1,45 @@
|
||||
/* What are the suppliers that supply all parts using NOT EXISTS */
|
||||
/* sp difference A */
|
||||
select DISTINCT snumber
|
||||
from spj as c
|
||||
where not EXISTS
|
||||
/* A */
|
||||
/* Cross Product */
|
||||
(select DISTINCT b.snumber
|
||||
from part as a cross join spj as b
|
||||
where c.snumber = b.snumber and not EXISTS
|
||||
/* difference cross product sp */
|
||||
(select snumber, pnumber from spj
|
||||
where b.snumber = spj.snumber and a.pnumber = spj.pnumber));
|
||||
|
||||
|
||||
/* What are the suppliers that supply all parts using NOT EXISTS * */
|
||||
/* sp difference A */
|
||||
select DISTINCT snumber
|
||||
from spj as c
|
||||
where not EXISTS
|
||||
/* A */
|
||||
/* Cross Product */
|
||||
(select *
|
||||
from part as a cross join spj as b
|
||||
where c.snumber = b.snumber and not EXISTS
|
||||
/* difference cross product sp */
|
||||
(select * from spj
|
||||
where b.snumber = spj.snumber and a.pnumber = spj.pnumber));
|
||||
|
||||
|
||||
/* What are the suppliers that supply all parts using NOT EXISTS *, list their names and their cities */
|
||||
select snumber, sname, city from supplier
|
||||
WHERE snumber in
|
||||
(/* sp difference A */
|
||||
select DISTINCT snumber
|
||||
from spj as c
|
||||
where not EXISTS
|
||||
/* A */
|
||||
/* Cross Product */
|
||||
(select *
|
||||
from part as a cross join spj as b
|
||||
where c.snumber = b.snumber and not EXISTS
|
||||
/* difference cross product sp */
|
||||
(select * from spj
|
||||
where b.snumber = spj.snumber and a.pnumber = spj.pnumber)));
|
||||
Reference in New Issue
Block a user