select a.id,a.info_a,b.b_info from table_a a,table_b b where a.id=b.id
order by a.id

解决方案 »

  1.   

    select A.ID,A.Info_A,B.Info_B from Table_A A,Table_B B where A.ID=B.ID(+)
      

  2.   

    select A.ID,A.Info_A,B.Info_B from Table_A A,Table_B B where A.ID=B.ID(+) order by A.iD
      

  3.   

    To ghl200(小面人) 如果出现A表少,而B表多的情况,该如何处理呢???
    谢谢!!!
      

  4.   

    那就这样啦:
    select A.ID,A.Info_A,B.Info_B from Table_A A,Table_B B where B.ID=A.ID(+) order by A.iD
    总之主表,附表的关系一般是这样的:主表.col=附表.col(+)
      

  5.   

    你所需要的数据主要是从哪个表取出的,那个表就是主表阿。你希望所后的结果是Info_A还是Info_B更重要些?哪个重要哪个就做主表。
      

  6.   

    Table_A,Table_B中的数据时通过查询实现的!!!又该如何去做???
      

  7.   

    同样呀,只不过将table_a,和table_b分别换成子查询就行了。
      

  8.   

    select a.id,a.info_a,b.b_info 
      from table_a a,table_b b 
      where a.id=b.id
    union all
    select a.id,a.info_a,' ' 
      from table_a a
      where not exists(select 1 from table_b where a.id=b.id)
    union all
    select a.id,' ',b.info_b
      from table_b b
      where not exists(select 1 from table_a where a.id=b.id)
    order by 1
      

  9.   

    select a.id,a.info_a,b.b_info 
      from table_a a,table_b b 
      where a.id=b.id
    union all
    select a.id,a.info_a,' ' 
      from table_a a
      where not exists(select 1 from table_b b where a.id=b.id)
    union all
    select a.id,' ',b.info_b
      from table_b b
      where not exists(select 1 from table_a a where a.id=b.id)
    order by 1
      

  10.   

    SELECT a.id,a.info_a,b.b_info 
      FROM table_a a,table_b b 
     WHERE a.id = b.id
    UNION ALL
    SELECT a.id,a.info_a,b.b_info 
      FROM table_a a,table_b b 
     WHERE a.id = b.id(+)
       AND b.id IS NULL
    UNION ALL
    SELECT a.id,a.info_a,b.b_info 
      FROM table_a a,table_b b 
     WHERE a.id(+) = b.id
       AND a.id IS NULL
    ORDER BY 1