mysql 查询

有这样一个需求

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

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

《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 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年前

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