取出 一张表中的记录  但   xxx  这个列的内容不能重复 这个SQL语句应该怎么写啊

解决方案 »

  1.   

    select * from tb where xxx in (select xxx from tb group by xxx having count(1) = 1)
      

  2.   

    select * FROM TB A WHERE NOT EXISTS(SELECT 1 FROM TB WHERE A.NAME=NAME AND ID>A.ID)
      --取最大
    select * FROM TB A WHERE NOT EXISTS(SELECT 1 FROM TB WHERE A.NAME=NAME AND ID<A.ID)
      --取最小
      

  3.   

    select distinct(xxx) from tb
      

  4.   

    select *
    from ta a
    where not exists(select 1 from ta where id > a.id and a.xxx = xxx)
      

  5.   

    select a.* from 表 a join (
    select xxx from 表
    group by xxx
    having count(*)=1
    ) b on a.xxx=b.xxx
      

  6.   

    http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html?73339又贴一次