【问题标题】:Combining Query Result sets in Oracle sql在 Oracle sql 中组合查询结果集
【发布时间】:2015-05-29 15:49:32
【问题描述】:

oracle SQL中如何组合多个查询结果集

示例查询是

选择 * 从表哪里

中的table.id

(

   (
    select table.id 
    from table 
    where cond 1 

    intersect

    select table.id 
    from table 
    where cond 2   
   ) 

联合
(

    select table.id 
    from table 
    where cond 3   

    intersect

    select table.id 
    from table 
    where cond 4

)
)

我想先得到相交结果,然后应该应用联合如何组合这样的两个结果集?

【问题讨论】:

  • 先得到相交结果是什么意思?这个查询没有给你预期的结果?

标签: sql oracle


【解决方案1】:

这样做怎么样?

Select *
from table
where ((cond 1) and (cond 2)) or
      ((cond 3) and (cond 4));

【讨论】:

  • 所以答案应该是 Select * from table where table.id in ((query1) and (query2)) or ((query 3) and (query 4));
猜你喜欢
  • 2017-02-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2012-12-23
  • 2017-03-24
  • 2021-07-02
  • 1970-01-01
相关资源
最近更新 更多