oracle 怎样将select 语句的查询结果作为另一个select 语句where 后面的查询条件

select sysdate
from dual
where (select case
when (zys - bjs = zys) then
'1=1 and xb=''1'''
when (abs(zys - bjs) = bjs) then
'2=2 and xb=''1'''
else
'3=3 and xb=''1'''
end
from (select (select count(*)
from jx0503tzd
where jx0404id = xk.jx0504id) zys,
(select count(*)
from jx0503tzdbj
where jx0404id = xk.jx0504id) bjs
from jx0504 xk
where xk.jx0504id = '201120122000571'))
类似这样的,当然这样是不行的

1、首先我们先看一下我们的这个表信息。

2、接着我们使用创建查询的方法,来测试sql。

3、select的where的条件查询格式:select 【所选字段列表】 from 【数据表名】 where 条件表达式。

4、上面那个是查询表中年龄大于10的数据。

5、当然如果你有多个条件也可以写,多个条件表达式。要是用and进行连接。and就是并且的意思。

温馨提示:内容为网友见解,仅供参考
第1个回答  推荐于2017-10-10
你这样太复杂了。

无非就是下面几种:
1. exists

where exists (select 1 from abc where xxx)

2. in

where xxx in (select xxx from abc where ...)

3. = (只能返回一行)
where xxx = (select xxx from abc where ...)

当然,子查询中是可以使用外部的表。

比如
select * from a where exists (select 1 from b where a.id = b.id)本回答被提问者采纳
第2个回答  2012-08-28
你后面的select 语句得到的是,一个字段值还是,一个table?这两个方式不一样
第3个回答  2015-09-22
select * from table_a
where (c,b) in (select c1,c2 from table_b )
第4个回答  2012-08-28
子查询
相似回答