mysql 查询

有这样一个需求

文章(articles)
文章 id 创建人 id 最佳回答人 id 是否公开
id creator_id answser_id is_open
文章 - 关注者(多对多)(followers)
文章 id 关注人 id
article_id follower_id
当公开时所有人可见
当不公开时,创建人,最佳回答人,文章关注者可见

这种的查询语句应该怎么写

《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《G01 Go 实战入门》
从零开始带你一步步开发一个 Go 博客项目,让你在最短的时间内学会使用 Go 进行编码。项目结构很大程度上参考了 Laravel。
最佳答案

select * from a join b on a.id = b.article_id where a.is_open = 1 or (a.is_open=0 and (a.creator_id=$uid or a.answer_id=$uid or b.follower_id=$uid))

3年前 评论
____ (楼主) 3年前
luke_wu (作者) 3年前
讨论数量: 2

检测到用户是关注者后,给出对应数据就好了

不一定总要一招制敌。

3年前 评论

select * from a join b on a.id = b.article_id where a.is_open = 1 or (a.is_open=0 and (a.creator_id=$uid or a.answer_id=$uid or b.follower_id=$uid))

3年前 评论
____ (楼主) 3年前
luke_wu (作者) 3年前

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!