{
"paths": {
"/": {
"post": {
"x-auth-type": "Application & Application User",
"x-throttling-tier": "Unlimited",
"x-mycustom-extension": "someValue", <-- How to get access to this?
"produces": [
"application/json"
],
"parameters": [
这是一个查询,它总是给我每条记录的第一个索引。但我想在每个组中得到最新的索引..我尝试了很多方法,但结果都没有。 用户:
答案 0 :(得分:-1)
尝试这个代码
SELECT * FROM msg_messages m
JOIN msg_status s on m.messageId = s.messageId
JOIN msg_threads t ON t.threadId = m.threadId
JOIN users u ON u.userId = s.userId
WHERE t.threadId = 1
GROUP BY u.userId ORDER BY `m`.`date` DESC LIMIT 0,1
答案 1 :(得分:-1)
怎么样:
SELECT * FROM msg_messages m
JOIN msg_status s on m.messageId = s.messageId
JOIN msg_threads t ON t.threadId = m.threadId
JOIN users u ON u.userId = s.userId
GROUP BY u.userId
having max (`m`.`date`)
ORDER BY `m`.`date` DESC
我从
修改了我的查询having max (`t`.`threadId`)
到
having max (`m`.`date`)
答案 2 :(得分:-1)
您可以在DESC之后使用LIMIT 1,然后您将获得最后一条记录。 例: DESC 限制1;