左边的表记为a ,右边为b
select value_description from a 
where exisit (select 1 from (select distinct bank_id id from b
                            union 
                            select distinct brand_id id from b
                            union 
                            select distinct check_flag id from b) c 
             where a.value=c.id)

解决方案 »

  1.   

    左边的表记为a ,右边为b,check_flag 是字符型吧,要转换下
    select value_description from a 
    where exisit (select 1 from (select distinct bank_id id from b
                                union 
                                select distinct brand_id id from b
                                union 
                                select distinct to_number(check_flag) id from b) c 
                 where a.value=c.id) 
      

  2.   

    我问题没有描述全面,我表中的那三个id字段是可以重复的,第一张表中的value也是可以重复的,第一张表结构完整如图,我想要的结果是通过第二张表的流水号查询一条记录,这条记录满足的条件是那三个字段只要的id在value中有,就把value对应的value_description显示出来,如果没有就为null(为它本身的id也行,这不重要),value中的值并不全部包含那三个字段的值,例如三个id为 bank_id (100812),brand_id(1),check_flag(50),这个50在value中是不存在的,我想要查询结果为:
    银行名字    品牌    对账
    工商银行    全球通  50或者为null也可以不知道描述清楚没有,麻烦你看看能不能解决 
      

  3.   

    select distinct 
           a1value as '银行名字',
           a2.value as '品牌’    
           a3.value as  '对账'
    from b,
         a a1,
         a a2,
         a a3
    where b.brank_id=a1.value(+)
      and b.brand_id=a2.value(+)
      and b.check_flag=a3.value(+)