【问题标题】:oracle sql query select [closed]oracle sql查询选择[关闭]
【发布时间】:2020-09-15 00:49:45
【问题描述】:

桌游

桌游

餐桌酒店

我想打印去过希尔顿而不是大陆的游客的名字,所以不应该打印去过希尔顿和大陆的游客

【问题讨论】:

  • 你很幸运,你得到了答案(而且做得很好)。通常你应该先自己尝试一下,然后询问是否卡住。
  • 请不要破坏这个问题,我把它回滚到以前的版本。

标签: sql oracle select oracle-sqldeveloper qsqlquery


【解决方案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'  
    )

【讨论】:

    猜你喜欢
    • 2018-04-30
    • 2023-03-09
    • 1970-01-01
    • 2013-07-17
    • 2012-12-30
    • 1970-01-01
    • 1970-01-01
    • 2014-03-17
    • 1970-01-01
    相关资源
    最近更新 更多