Oracle SQL查询选择[关闭]

问题描述 投票:-1回答:1

餐桌游客

enter image description here

餐桌停留

enter image description here

餐桌酒店

enter image description here

我想打印曾去过希尔顿但不去过大陆的游客的姓名,所以不应该去过曾经去过希尔顿和大陆的游客的名字

sql oracle select oracle-sqldeveloper qsqlquery
1个回答
1
投票
您可以使用existsnot exists

select t.* from tourists t where exists ( select 1 from stay s inner join hotels h on h.hcode = s.hcode where s.tcode = t.tcode and h.name = 'Hilton' ) and not exists ( select 1 from stay s inner join hotels h on h.hcode = s.hcode where s.tcode = t.tcode and h.name = 'Continental' )

© www.soinside.com 2019 - 2024. All rights reserved.