我的SQL是
select t.*,b.b4 from
(
select b.n1,b.n2.b.n3,count(a.n1) a4 from a,b, where a.id=b.id group by a.n1,a.n2.a.n3
) t
full join
(
select b.n1,b.n2.b.n3,count(a.n1) b4 from a,b, where a.id=b.id group by a.n1,a.n2.a.n3
) r
on t.n1=r.n1 and t.n2=r.n2 and t.n3=r.n3注:两个表名 a 是不相同的两张表
结果:
如当 别名 t表中无记录,而别名 r表中有一条记录时,取出二条记录,但字段值都是空的
是否那里有错??谢谢

解决方案 »

  1.   

    select t.*,r.* from
    (
    select b.n1,b.n2.b.n3,count(a.n1) a4 from a,b, where a.id=b.id group by a.n1,a.n2.a.n3
    ) t
    full join
    (
    select b.n1,b.n2.b.n3,count(a.n1) b4 from a,b, where a.id=b.id group by a.n1,a.n2.a.n3
    ) r
    on t.n1=r.n1 and t.n2=r.n2 and t.n3=r.n3 看看。
      

  2.   

    "select b.n1,b.n2.b.n3,count(a.n1) a4 from a,b, where a.id=b.id group by a.n1,a.n2.a.n3 "
    from關鍵字后面多了個逗號
      

  3.   

    你的SQL有问题吧,除了那个逗号以外,查询的使用b.b4,可当前层根本就没有别名为b的表?另外最好把所有的表名的别名不要设成相同的.