MySQL选择一列DISTINCT,与对应的其他列

2021-11-20 00:00:00 mysql
ID   FirstName   LastName
1      John        Doe
2      Bugs        Bunny
3      John        Johnson

我想从 FirstName 列中选择 DISTINCT 结果,但我需要相应的 IDLastName.

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)

相关文章