假设有一个表article(title,author,pubdate)
现在想从表里面读取所有的文章,如果有title或者author相同 只选择最先读取的那条数据,请问应该怎么写

解决方案 »

  1.   

    贴记录及要求结果贴出来看看
    如果有title或者author相同 只选择最先读取的那条数据
    什么标准
      

  2.   

    比如有两条记录分别为
    id  title   author   pubdate
    1   title1  author1  pubdate1
    2   title1  author2  pubdate2
    这时想只读出id为1的记录 不读取id为2的记录
      

  3.   


    select distinct * from article;
      

  4.   

    select a.* from tt a
    left join
    (select title,min(id) as mi from tt group by tt )b
    on a.title=b.title and a.id=b.mi
      

  5.   

    谢谢 试过了。。
    还有请问如果我想先找出title不重复的记录,再在这些记录里面找出author不相同的记录应该怎么写
      

  6.   

    比如有两条记录分别为
    id  title   author   pubdate
    1   title1  author1  pubdate1
    2   title1  author2  pubdate2
    这时想只读出id为1的记录 不读取id为2的记录select title,author,min(pubdate)
    from article
    group by title,author
      

  7.   

    先找出title不重复的记录,再在这些记录里面找出author不相同的记录应该怎么写
    如果是这样
    先找出title,author不重复的记录,再在这些记录里面找出author不相同的记录应该怎么写select distinct author
    from (select distinct title,author
    from article) t;