使用子查询连接从表中获取多条记录
SELECT
COUNT(*) AS total_count,
(SELECT
chat_box.user_id,
chat_box.message,
members.id,
members.display_name
FROM chat_box INNER JOIN members
ON chat_box.user_id = members.id
ORDER BY chat_id DESC LIMIT 1),
(SELECT COUNT(DISTINCT user_id) FROM chat_box) AS users_count
FROM chat_box
这就是我到目前为止所拥有的,我想members.display_name
从内部连接中获取chat_box.user_id = members.id
作为输出的内部连接,并将其chat_box.message
保存members.display_name
到chat_box.message
变量中。任何帮助表示赞赏。