1.select num,date,nam
from a,b
where a.id=b.id 2.select num,date,''
from a,b
where a.id is null我是这样合并的
select num,date,nam
from a,b
where a.id=b.id or a.id is null 但这样合并后a.id为空的数据中 nam字段自动补了b表中所有的nam。应该怎么处理这个语句,谢谢指点!

解决方案 »

  1.   

    select num,date,nam 
    from a,b 
    where a.id=b.id 
    union all
    select num,date,'' 
    from a,b 
    where a.id is null 
      

  2.   

    select num,date,nam 
    from a right join b 
    on a.id=b.id 
      

  3.   

    select num,date,nam from a right join b on a.id=b.id 
      

  4.   

    select num,date,nam 
    from a,b 
    where a.id=b.id 
    union all
    select num,date,'' 
    from a,b 
    where a.id is null 
      

  5.   

    select num,date,nam 
    from a,b 
    where a.id=b.id 
    union all
    select num,date,'' 
    from a,b 
    where a.id is null