【发布时间】:2019-01-18 10:35:39
【问题描述】:
我想选择具有不同电子邮件的行,请参见下面的示例表:
表名 = 用户
+----+---------+-------------------+-------------+
| id | title | email | commentname |
+----+---------+-------------------+-------------+
| 3 | test | rob@hotmail.com | rob |
| 4 | i agree | rob@hotmail.com | rob |
| 5 | its ok | rob@hotmail.com | rob |
| 6 | hey | rob@hotmail.com | rob |
| 7 | nice! | simon@hotmail.com | simon |
| 8 | yeah | john@hotmail.com | john |
+----+---------+-------------------+-------------+
期望的结果是:
+----+-------+-------------------+-------------+
| id | title | email | commentname |
+----+-------+-------------------+-------------+
| 5 | its ok| rob@hotmail.com | rob |
| 7 | nice! | simon@hotmail.com | simon |
| 8 | yeah | john@hotmail.com | john |
+----+-------+-------------------+-------------+
不同的值应该是表示例id = 6 中的最新条目
所需的 SQL 是什么?
【问题讨论】:
-
最新行不是
id = 6吗? -
我的错应该是
6
标签: mysql