比如有两条记录分别为 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
先找出title不重复的记录,再在这些记录里面找出author不相同的记录应该怎么写 如果是这样 先找出title,author不重复的记录,再在这些记录里面找出author不相同的记录应该怎么写select distinct author from (select distinct title,author from article) t;
如果有title或者author相同 只选择最先读取的那条数据
什么标准
id title author pubdate
1 title1 author1 pubdate1
2 title1 author2 pubdate2
这时想只读出id为1的记录 不读取id为2的记录
select distinct * from article;
left join
(select title,min(id) as mi from tt group by tt )b
on a.title=b.title and a.id=b.mi
还有请问如果我想先找出title不重复的记录,再在这些记录里面找出author不相同的记录应该怎么写
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
如果是这样
先找出title,author不重复的记录,再在这些记录里面找出author不相同的记录应该怎么写select distinct author
from (select distinct title,author
from article) t;