我的ERD看起来像和
我正在制作聊天列表屏幕API,我想向客户端提供聊天伙伴的名字(user.name)和消息的最新内容(message.content)。
因此,我对MySQL进行了查询。
select u.name, m.content
FROM chat_room as c
INNER JOIN message as m on m.sender_no = c.user_type_2 or c.user_type_2 = m.reciver_no
INNER JOIN user as u on u.user_no= c.user_type_2
WHERE c.user_ty