数据库,帮忙分析一下这两道题,谢谢!!

2025-05-11 11:25:45
推荐回答(1个)
回答(1):

第一个的写法很多。

全嵌套的写法:

select jname from j where jno in (select jno from spj where sno in (select sno from s where city='上海'))

关联写法:

select j.jname from s,j,spj where s.sno=spj.sno and j.jno=spj.jno and s.city='上海'

第二个最简单的写法就是把所有的工程名减去用了天津生产零件的工程名:

select jname from j
except
select jname from j where jno in (select jno from spj where sno in (select sno from s where city='天津'))