ID FirstName LastName
1 John Doe
2 Bugs Bunny
3 John Johnson
我想从 FirstName
列中选择 DISTINCT
结果,但我需要相应的 ID
和 LastName
.
I want to select DISTINCT
results from the FirstName
column, but I need the corresponding ID
and LastName
.
结果集只需要显示一个 John
,但 ID
为 1,LastName
为 Doe.
The result set needs to show only one John
, but with an ID
of 1 and a LastName
of Doe.
试试这个查询
SELECT ID, FirstName, LastName FROM table GROUP BY(FirstName)
这篇关于MySQL选择一列DISTINCT,与对应的其他列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!