select distinct table.字段名 from table;
(查找字段名唯一, 用关键字distinct)

解决方案 »

  1.   

    不好意思, 没有看见限制条件 要用where
      

  2.   

    没有太明白,不过,你要想在where中实现distinct,你就必须使用子查询:
    select * from biao a where col = (select distinct col from biao b where ...)
      

  3.   

    disitinct应该是关联组合查询用的,一个字段有意义吗?
      

  4.   

    select * from biao where id in (select distinct id from biao where ...)
      

  5.   

    select * from biao a where colname exists (select colname,count(*) from biao b where a.colname =  b.colname group by colname having count(*)>1)
      

  6.   

    不好意思,写反了!
    应该having count(*) = 1;
      

  7.   

    to  zakat():你那个是仅查询出一条数据时可以用
    to dinya2003(OK):不用in行吗?
    to wupangzi(无本之木) :oracle里exists 不是关系运算符
      

  8.   

    楼主,我好象不太清楚什么是关系运算符,我现在只知道,exists这东西可以用!
      

  9.   

    to wupangzi(无本之木) : 在Pl/sql里exists好像不能select * from biao a where colname exists (select colname,count(*) from biao b where a.colname =  b.colname group by colname having count(*)>1) 这么用,提示错误,好像可以在SQL sever这么用
      

  10.   

    同意netcreator的意见,你做这个查询的目的是什么?是只输出每个关键字对应的第一行吗。不排序的话,很可能由于记录在表中顺序的不同,而导致查询的结果不同的
      

  11.   

    楼主,不好意思多写了个colname;
    疏忽,实在抱歉!但是ORACLE也是可以用exists的!
    select * from biao a where exists (select colname,count(*) from biao b where a.colname =  b.colname group by colname having count(*)>1)