A表 
id
1
2
3B表
id
2
3
4
5
C表
id
2
4
5怎么把三张表id=2的都查出来

解决方案 »

  1.   

    什么意思  3表有关系么? 去重么 ?select id from A
    union --all
    select id from B
    union --all
    select id from C
      

  2.   

    木看到到2  查询id=2的 直接where id=2不可以了么?
      

  3.   

    三张表join起来
    select a.*,b.*,c.* from a, b, c where a.id=b.id and b.id=c.id and a.id=2;
      

  4.   

    select count(1) as totalrow
      from (select t2.onenum,
                   t2.allnum,
                   t2.printstatus,
                   t.apfd_code,
                   t2.gidl_doc_numb,
                   t2.orgid,
                   t.bdgt_subj,
                   t3.subjectcode,
                   t3.subjectname,
                   case
                     when t.acst_id not in
                          (887209, 2001, 3001, 4001, 5001, 7001, 8001, 6066768) then
                      decode(t2.fund_char,
                             '0',
                             '预算内',
                             '1',
                             '其他财政性资金',
                             '2',
                             '其他',
                             '3',
                             '预算内(往年)',
                             '4',
                             '其他财政性资金(往年)',
                             '5',
                             '其他(往年)')
                     else
                      '其他'
                   end as fund_char,
                   t2.pay_amnt,
                   t2.dtal_id,
                   t2.item,
                   t4.name,
                   t.gath_org_name,
                   t2.smry smry,
                   t.acst_id
              from ga_t_apfd_bill      t,
                   sysmgr_org          t1,
                   ga_t_apfd_bill_dtal t2,
                   busmgr_funnew       t3,
                   sysmgr_user         t4
             where 1 = 1
               and t.gath_org_id = t1.orgid(+)
               and t.bdgt_subj = t3.subjectcode(+)
               and t.apfd_user_id = t4.userid(+)
               and t2.apfd_bill_id = t.apfd_bill_id
               and t.year = 2012
               and t3.year = 2012
               and t.ACST_ID = 1001
               and t.is_Del = 0
               and t.status in ('4', '5')
               and t2.gidl_doc_numb like % '414%'
             order by t1.orgcode, t.bdgt_subj, to_number(t.APFD_CODE))这段哪儿错了??
      

  5.   


    中and t2.gidl_doc_numb like % '414%'
    改为and t2.gidl_doc_numb like '%414%'试试
      

  6.   

    select a.*,b.*,c.* from a, b, c where a.id=b.id and b.id=c.id and a.id=2;