select a.keyword,a.type,b.pathname, max(a.material_id) as abc  from  mms_key_material as a  inner join mms_material as b on  a.material_id=b.id where a.type='2'             group by  a.keyword,a.type,b.pathname  order by abc
上面查询出来 还是有重复列!!
我想消取a.material_id重复列 怎么写?

解决方案 »

  1.   

    a.keyword,a.type,b.pathname 因为这三有不同的呀1  2  3   a
    1  2  4   a
      

  2.   

    material_id,a.keyword,a.type,b.pathname
    1              1         1       2
    1              1         1       3
      

  3.   

           你分组的字段是a.keyword,a.type,b.pathname !给出数据,直接说你想要什么样的结果.
      

  4.   

         你是想pathname相同的只显示一条记录吗?
      

  5.   

    消取a.material_id重复列就是 上面显示的abc
      

  6.   


    select a.keyword,a.type,b.pathname, abs=(select max(a.material_id) from  mms_key_material c where c.material_id=a.material_id and c.type='2 )
     from mms_key_material as a inner join mms_material as b 
    on a.material_id=b.id 
    where a.type='2' 
    group by a.keyword,a.type,b.pathname --可试一下去掉效果
     order by abc
      

  7.   

    select a.keyword,a.type,b.pathname, abs=(select max(a.material_id) from  mms_key_material c where c.material_id=a.material_id and c.type='2' )
     from mms_key_material as a inner join mms_material as b 
    on a.material_id=b.id 
    where a.type='2' 
    group by a.keyword,a.type,b.pathname --可试一下去掉效果
     order by abc
      

  8.   

    会不会是INNER JOIN 的时候mms_material 这张表里有重复的a.material_id 记录呢
    试试这个select a.keyword,a.type,b.pathname, 
    max(a.material_id) as abc 
    from mms_key_material as a inner join 
    (SELECT DISTINCT material_id FROM mms_material)b
    on a.material_id=b.id 
    where a.type='2' 
    group by a.keyword,a.type,b.pathname 
    order by abc
      

  9.   

    哦,我错了,不要理我写的   %>_<%