我想运行一个查询,在那里我可以得到一个字段唯一的所有字段
Select * from announcements where title = SELECT distinct title FROM announcements;
但它不起作用。谁能帮帮我吗。
r7knjye21#
Select * from announcements where title in (SELECT distinct title FROM announcements)
7lrncoxx2#
此查询:
select title from announcements group by title having count(*) = 1
返回所有唯一标题。与操作员一起使用 IN :
IN
select * from announcements where title in ( select title from announcements group by title having count(*) = 1 )
yxyvkwin3#
试着用圆括号类似:从标题所在的公告中选择*(从公告中选择不同的标题);
xbp102n04#
谢谢大家。我得到了我想要的东西
SELECT MIN( id ) AS id, title, issue_date, expirty_date, is_active FROM announcements GROUP BY title ORDER BY issue_date DESC
4条答案
按热度按时间r7knjye21#
7lrncoxx2#
此查询:
返回所有唯一标题。
与操作员一起使用
IN
:yxyvkwin3#
试着用圆括号
类似:从标题所在的公告中选择*(从公告中选择不同的标题);
xbp102n04#
谢谢大家。我得到了我想要的东西