
oracle怎么用查询结果当作where条件?
在oracle中casewhen只能用在结果中,要达到下面语句的效果,需要怎么写语句?select*fromt_webwherecasef2when'all'thenor...
在oracle中case when 只能用在结果中,要达到下面语句的效果,需要怎么写语句?
select * from t_web where
case f2
when 'all' then orgid in ('1000','2000','3000','1')
when 'part' then f4 like '%7275765e731549f0bfa24c83151d4134%'
when 'owner' then orgid='1' end
order by sortid,topid asc,releasetime desc
是要达到这种效果:
当查询出f2的值是all的时候,查询条件是orgid in ('1000','2000','3000','1'),
当查询出f2的值是part的时候,查询条件是of4 like '%7275765e731549f0b%',
当查询出f2的值是owner的时候,查询条件是orgid='1'。 展开
select * from t_web where
case f2
when 'all' then orgid in ('1000','2000','3000','1')
when 'part' then f4 like '%7275765e731549f0bfa24c83151d4134%'
when 'owner' then orgid='1' end
order by sortid,topid asc,releasetime desc
是要达到这种效果:
当查询出f2的值是all的时候,查询条件是orgid in ('1000','2000','3000','1'),
当查询出f2的值是part的时候,查询条件是of4 like '%7275765e731549f0b%',
当查询出f2的值是owner的时候,查询条件是orgid='1'。 展开
1个回答
2017-08-28
展开全部
oracle怎么用查询结果当作where条件?
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 ...)
当然,子查询中是可以使用外部的表。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询