id name
1   a
2   b
3   b
4   c我想要查询不重复的记录怎么查询?
也就是 查出来的结果是id (1,4)

解决方案 »

  1.   

    本帖最后由 ACMAIN_CHM 于 2012-01-09 13:04:48 编辑
      

  2.   

    select * from table1 a where not exists (select 1 from table1 where name = a.name)
      

  3.   

    SELECT MAX(id) FROM table1 GROUP BY name HAVING COUNT(*)=1
      

  4.   

    select id from t group by name having count(*) = 1;
      

  5.   

    select * from table a 
    where not exists (select 1 from table1 where a.name=name)
      

  6.   

    select id,name,count(name) a 
    from tableName
    group by name
    having a=1
    这样的主要问题是你的数据多吗?name有没有索引,不然可能效率会有影响。
      

  7.   

    liuxinran819
    此好汉,方法较好,绿色且速度快。洒家顶之。
      

  8.   

    select * from t group by name having count(*) = 1;