【发布时间】:2014-12-04 05:51:54
【问题描述】:
我在sql中有这种类型的数据库表
id | state | msg | userid | time |
1 |unread | hi | 1 | time |
2 |unread |hello| 1 | time |
3 |unread | hi | 2 | time |
4 | read | hi | 2 | time |
我有打印行的传导
Where state=unread
现在输出是
= userid 1 send you 'hi'
= userid 1 send you 'hello'
= userid 2 send you 'hi'
但我想这样输出
= userid 1 send you 'hello'
= userid 2 send you 'hi'
删除相同的用户 ID 行并只选择最后一个(使用 php 和 sqli)
【问题讨论】:
标签: mysql sql select group-by greatest-n-per-group