oracle 怎样将select 语句的查询结果作为另一个select 语句where 后面的查询条件
selectsysdatefromdualwhere(selectcasewhen(zys-bjs=zys)then'1=1andxb=''1'''when(abs(zy...
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'))
类似这样的,当然这样是不行的 展开
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'))
类似这样的,当然这样是不行的 展开
5个回答
展开全部
你这样太复杂了。
无非就是下面几种:
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)
无非就是下面几种:
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)
本回答被提问者采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
你后面的select 语句得到的是,一个字段值还是,一个table?这两个方式不一样
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
select * from table_a
where (c,b) in (select c1,c2 from table_b )
where (c,b) in (select c1,c2 from table_b )
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询