table(ms_replies)
|------------------------------------------|
| id | ticketID | replyStamp |
|------------------------------------------|
| 1 | 7 | Tue 11 Oct 2011, 8:56am |
| 2 | 7 | Wed 12 Oct 2011, 9:20am |
| 3 | 8 | Wed 12 Oct 2011, 16:24pm |
| 4 | 7 | Thu 27 Oct 2011, 20:28pm |
| 5 | 8 | Tue 18 Oct 2011, 9:54am |
|------------------------------------------|
到目前为止我的代码是:
SELECT
ticketID,
MAX(replace(replace(replyStamp, 'pm',''), 'am','')) AS time
FROM
ms_replies
WHERE
`ticketID` IN ($IDs)
GROUP BY
ticketID
但这不会返回最近的条目。
请注意replace
查询中的必须删除 am | pm ,这不是我做的,但不幸的是,我无法改变它。