或者在 Select Oracle 中

OR in Select Oracle

select * from table1 t1 where t1.column1 = 'someValue' and ((t1.column2 =1) OR  (sysdate < select t1.DateColumn2 + t2.DateColumn2/1440
      from
    table2 t2 where t1.column3 = t2.column3));

如果 t1.column2 =1 的计算结果为假,我想检查另一个条件,如果时间 t1.DateColumn2 + t2.DateColumn2 是 < sysdate 。 Oracle 在 or 条件附近抛出语法错误。这样直接用sysdate不行吗?不知道我要去哪里错了。谢谢

如果我没猜错你的意图,你需要一个 exists 子句

select * 
  from table1 t1 
 where t1.column1 = 'someValue' 
   and (   (t1.column2 =1) 
        OR exists( select 1
                     from table2 t2
                    where t2.column3 = t1.column3
                      and sysdate < t1.DateColumn2 + t2.DateColumn2/1440 ));

或者只是在外部查询中连接两个表,假设每个 t1 行在 t2 中最多有 1 行(如果恰好有 1 行,您应该进行内部连接而不是左外连接)

select t1.*
  from table1 t1
       left outer join table2 t2
         on( t1.column3 = t2.column3 )
 where t1.column2 = 1
    or sysdate < t1.DateColumn2 + t2.DateColumn2/1440;