1. 需求
根据通知表(tb_notification)中的用户ID(user_id),按时间倒序查询该用户所在房间所有人发出的通知。(用户所在的房间ID需要在用户表(tb_user)中查询)
2. 表结构与部分数据
-
通知表(tb_notification)
-
用户表(tb_user)
3. 查询语句
select * from tb_notification
where
(select room_id from tb_user
where tb_user.id = tb_notification.user_id) =
(select room_id from tb_user
where tb_user.id = 20200011)
order by noti_date desc
4. 结果

5. 前端显示

相关内容