select id,name,tel from tb group by id,name,tel

解决方案 »

  1.   

    select distinct name from yy
    id 不应是主键!
      

  2.   

    select distinct name from yy
    id 不应是主键!
      

  3.   

    select id,name,tel from tb group by id,name,tel
      

  4.   

    如果 id 和name 一一对应  (id不是主键)select distinct * from yy如果 id 和name  不是一一对应  (id是主键)select max(id),name,tel from tb group by name,tel    --取最大的id
      

  5.   

    select distinct * from yy
      

  6.   

    在yy表中,id 如果作为主键的话,这个字段的值就不能出现重复。你提供的数据就有错误。
    就你现在的表中的数据要想得到那样的查询结果的话,你可以这样完成:--测试语句:
    create table yy(id varchar(4) ,name varchar(8),tel varchar(16))
    --插入数据
    insert yy select '001','jim','010-2654815'
    union all select '003','smish','029-6235844'
    union all select '001','jim','010-2654815'
    union all select '001','jim','010-2654815'
    union all select '003','smish','029-6235844'
    --select * from yy ---你可以这样查询:
    select distinct * from yy 
    ---也可以这样查询:
    select * from yy group by id ,name,tel
      

  7.   

    select distinct name from yy
    select distinct id from yy
    不过主键设置确实有错,主键不能有重复的。
      

  8.   

    select id,name,tel from tb group by id,name,tel
    与select distinct * from yy
    有什么不同?
      

  9.   

    select distinct * from yy