下面的查询对我来说很好,除了message_content列中的内容是表al_messages的第一行。如何获取最新行的内容?
SELECT a.CONVERSATION_ID,
a.CREATOR_ID,
c.SCREEN_NAME AS creator_screen_name,
c.FIRST_NAME AS creator_first_name,
c.LAST_NAME AS creator_last_name,
Count(d.MESSAGE_ID) AS messages_count,
MESSAGE_CONTENT
FROM AL_CONVERSATIONS a
INNER JOIN AL_SUBJECTS b
ON a.SUBJECT_ID = b.SUBJECT_ID
INNER JOIN AL_MEMBERS c
ON a.CREATOR_ID = c.MEMBER_ID
INNER JOIN AL_MESSAGES d
ON a.CONVERSATION_ID = d.CONVERSATION_ID
WHERE a.SUBJECT_ID = 301
AND b.CREATOR_ID = 17
GROUP BY a.CONVERSATION_ID
查询结果: