select * from 
(    select * from .....) as a
left join (    select * from .....) as b
on a.id = b.id

解决方案 »

  1.   

    select * from 
    (    select * from .....) as a,
    (    select * from .....) as bwhere  a.id=*b.id
      

  2.   

    把* 改为a.*
    select a.* from 
    (    select * from .....) as a,
    (    select * from .....) as bwhere  .....
      

  3.   

    select * from test a 
    left join test11 b on a.id=b.id
      

  4.   

    意思是这样:
    select a.*, b.field_1  from 
    (    select * from .....) as a,
    (    select b.field_1 from .....) as bwhere  a.id=b.id
    a有数据,而b为空,
    为何输出就空了,如何才能在b无数据的时候让a的数据输出,不知这样大家有没有明白?
      

  5.   

    select a.*, b.field_1  from 
    (    select * from .....) as a,
    (    select b.field_1 from .....) as bwhere  a.id=b.id  --因为没有符合条件的记录,所以无结果
      

  6.   

    --改为这个就行了.
    select a.*, b.field_1  from 
    (select * from .....) as a left join
    (select b.field_1 from .....) as b
    on a.id=b.id
      

  7.   

    如果子查询中没有where条件,就不要写成子查询,直接用原表:select a.*, b.field_1
    from table1 a left join table2 b on a.id=b.id
      

  8.   

    如果a表和b表结构相同,
    select u.* from 
    ((    select * from .....) as a
    union all
    (    select * from .....) as b
    ) as u