---这里的保证id的值是唯一的select name,id,actor,content 
from temp t
where exists(select 1 from temp where t.name=name and t.id>id)

解决方案 »

  1.   

    select name,id,actor,content 
    from temp a inner join (select min(id),name from temp group by name) b on a.id=b.id
      

  2.   

    select name,id,actor,content  from table as T
    where id =(select min(id) from table where name=T.name)
      

  3.   

    shuai45(付出总有回报,要做就做最好.) --------------------------你的写法有问题
    select name,id,actor,content  from table as T
    where id in (select min(id) from table where name=T.name) ---这个地方要用in不是等号
      

  4.   

    name重复怎么取数,其它内容是按id大的还是小的,看来shuai45(付出总有回报,
    的很好,要按大的改成max
      

  5.   

    各子表的数据是不会重复的,因为多表关联而产生的重复又怎么处理(产生原因是a表的program_id会同时属于vod_menu2program里的多个program_menu_id):
    原语句是
    select distinct a.program_id,a.name,a.director,a.playactor,d.count_total from vod_program a,vod_menu2program b,vod_program_menu c,vod_program_stat d  where a.program_id=b.program_id and b.program_menu_id=c.program_menu_id and a.program_id=d.program_id and c.parent_id=239 and a.if_issue=1 and a.if_check=1 
    现在因为要加输出content
    select distinct a.program_id,a.name,a.director,a.playactor,a.content,d.count_total from vod_program a,vod_menu2program b,vod_program_menu c,vod_program_stat d  where a.program_id=b.program_id and b.program_menu_id=c.program_menu_id and a.program_id=d.program_id and c.parent_id=239 and a.if_issue=1 and a.if_check=1 
    就不能用distinct了我用上面各位的方法无法解决这个问题
      

  6.   

    各子表的数据是不会重复的,因为多表关联而产生的重复又怎么处理(产生原因是a表的program_id会同时属于vod_menu2program里的多个program_menu_id):
    原语句是
    select distinct a.program_id,a.name,a.director,a.playactor,d.count_total from vod_program a,vod_menu2program b,vod_program_menu c,vod_program_stat d  where a.program_id=b.program_id and b.program_menu_id=c.program_menu_id and a.program_id=d.program_id and c.parent_id=239 and a.if_issue=1 and a.if_check=1 
    现在因为要加输出content
    select distinct a.program_id,a.name,a.director,a.playactor,a.content,d.count_total from vod_program a,vod_menu2program b,vod_program_menu c,vod_program_stat d  where a.program_id=b.program_id and b.program_menu_id=c.program_menu_id and a.program_id=d.program_id and c.parent_id=239 and a.if_issue=1 and a.if_check=1 
    就不能用distinct了我用上面各位的方法无法解决这个问题
    各位再帮我想想
      

  7.   

    你的sql 写的好乱~看看下面的能否执行select a.program_id,a.name,a.director,a.playactor,a.content,d.count_total from vod_program a,vod_menu2program b,vod_program_menu c,vod_program_stat d  where a.program_id=b.program_id and b.program_menu_id=c.program_menu_id and a.program_id=d.program_id and c.parent_id=239 and a.if_issue=1 and a.if_check=1 and
    a.program_id in (select min(a.program_id) from vod_program  where name=a.name)
     
      

  8.   

    大哥你提问的时候 能不能将长的sql写的结构化一些,让人有心情看
    如:
    select .........
    from ........
    inner join .........
    inner join .........
    where
      ...............
    group by ...........