简体   繁体   English

在几列上使用 SELECT DISTINCT - 但显示表的所有其他列

[英]Using SELECT DISTINCT on a few columns - but show all other columns of table

When I use:当我使用:

SELECT DISTINCT first_name, last_name 
FROM books;

不同的过滤列表

It sorts out all the authors by first and last name in my data set but only shows those two columns.它按我的数据集中的名字和姓氏对所有作者进行排序,但只显示这两列。

Is there a way to include all other rows of the data table, not just the two listed in the SELECT DISTINCT ?有没有办法包含数据表的所有其他行,而不仅仅是SELECT DISTINCT中列出的两行?

Normally SELECT * FROM books;通常SELECT * FROM books; shows everything.显示一切。 满桌

Is there a command to make it so it filters out the authors that are unique by their first and last name but include all other rows as well?是否有一个命令可以使它过滤掉他们的名字和姓氏唯一但也包括所有其他行的作者?

Thanks!谢谢!

I think I understand!我想我明白! I am asking the wrong question.我问错了问题。 The DISTINCT comand lists the unique sets. DISTINCT 命令列出唯一集。 Which could have more than row for each!每个可能有多个行! So it woudn't make sense to do what I am asking...所以按照我的要求去做是没有意义的...... 在此处输入图像描述

For instance Dave Eggers has three collumns that could be possibly be associated with the filtered DISTINCT row.例如,Dave Eggers 有三个列,它们可能与过滤后的 DISTINCT 行相关联。 So which one would it choose ect.那么它会选择哪一个等等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM