select a.A ...from a,b where a.a=b.a and.......
去掉b.a吧

解决方案 »

  1.   

    结果重复,往往是由于关联条件不够,如例:
    select a.A,b.A, ... ... from a,b
    where a.A = b.A如果 A,B表的A字段都是主键,绝对不会重复还有,可能本来记录是不同的,但是由于你所选择的字段不多,也会造成选择的字段重复,这个可以加DISTINCT过滤。select DISTINCT a.A,b.A, ... ... from a,b
    where a.A = b.A and ...
      

  2.   

    因为b表的A有重复?
    select a.A, c.A, ... ...
    from a, (select distinct A from b) c
    where a.A = c.A and ...
      

  3.   

    列重复还是结果集重复?
    列重复就去掉a.A,b.A中的一个。
    结果重复就distinct
      

  4.   

    the A column in table a or table b is not unique, so there will retrive some duplicate rows.
      

  5.   

    说详细点。
    a,b 两表中都有字段A,B,date(月底日期),分别按字段A,B,C聚集,没有重复。
    我想通过a,b关联,确定a中一条记录(取这条记录的某几个字段),我这样写的:
    update c
    set c.C = ( select a.C from a,b
                where a.A = b.A and a.B = b.B 
                      and a.date = '2001-12-31' and b.date = '2001-12-31' )
    结果,select的结果有重复的,看了一下,发现,选出的结果集重复(每条记录出现两次)。
    不知道为什么?
    谢谢大家帮助!来者都有分,:)
      

  6.   

    select a.C,b.C from a,b
    where a.A = b.A and a.B = b.B 
          and a.date = '2001-12-31' and b.date = '2001-12-31' )
    如果需要这样的查询,怎样才能避免重复呢?
      

  7.   

    select distinct a.C,b.C from a,b
    where a.A = b.A and a.B = b.B 
          and a.date = '2001-12-31' and b.date = '2001-12-31' 
      

  8.   

    select case when a.C > b.C then a.C else b.C end from a,b
    where a.A = b.A and a.B = b.B 
          and a.date = '2001-12-31' and b.date = '2001-12-31' )
    如果需要这样的查询,怎样才能避免重复呢?
    我需要这样的结果,怎么办?
      

  9.   

    我也依蓝天的画瓢:
    select distinct(case when a.C > b.C then a.C else b.C end)yourcolumn from a,b
    where a.A = b.A and a.B = b.B 
          and a.date = '2001-12-31' and b.date = '2001-12-31' 
      

  10.   

    to:superjj2002() 
    我被你的
    update c
    set c.C = ( select a.C from a,b
                where a.A = b.A and a.B = b.B 
                      and a.date = '2001-12-31' and b.date = '2001-12-31' )
    吓一跳,幸亏子查询返回多条,否则,我估计你惨了!
      

  11.   

    除非a表中(A,B,data)为primary key.