加一列自增主键alter table tb add int not null auto_increment primary key;select *
from tb A
where not exists(select 1 from tb A.type=type and A.name1=name1 and A.name2=name2 and A.id>id);

解决方案 »

  1.   

    select name1,name2,type
    from 始表格
    group by name1,name2
      

  2.   

    谢谢斑竹支持~
    我修改后可用的完整代码是:
    alter table tb ADD ID INT UNSIGNED not null auto_increment,ADD primary key(ID);
    select *
    from tb A
    where not exists(select 1 from tb WHERE A.type=type and A.name1=name2 and A.name2=name1 and A.ID>ID);
    目前还在理解消化中