select * from table1 where a_id in (select a_id from table1 group by a_id) and a_name in (select a_name from table1 group by a_name)

解决方案 »

  1.   

    既然一一对应,怎么可能a_id不重复而a_name还重复?
      

  2.   

    select a_id,a_name from table1 gruop by a_id,a_name
      

  3.   

    select distinct a_id,distinct  a_name from table1 where ....
      

  4.   

    其实可能是楼主的理解有误
    比如a_id ,a_name
    1      111
    2      111  
    3      222 
    4      444
    5      555  
    6      666这组数据用distinct就无法得出你要的数据
    因为程序不知道你是要 
    1      111  
    3      222 
    4      444
    5      555  
    6      666
    呢还是要
    2      111  
    3      222 
    4      444
    5      555  
    6      666应该是你描述的条件不够
      

  5.   

    同意letsflytogether(恨!不能拥有天下所有的财富,然后平分) 的观点。
      

  6.   

    不好意思,我昨天就调好了,可以的,写错了。
    一一对应肯定是只取一列。
    是我错了,抱歉。
     txlicenhe(马可&不做技术高手) 
    letsflytogether(恨!不能拥有天下所有的财富,然后平分) 
    二位厉害:)