假设有一个社交网络,我想向我的登录用户展示他的群组/朋友/家人的最新活动
我在registry
表中有所有活动,每个活动有 3 个不同的级别
0 => every one can see it
1 => only friends or in case of group, members can see it
2 => only family members can see it
我也有 2 个包含登录用户的数组friends_groups AND family
select * from registry where user_id in (implode(',' , $groups_friends_array) ) && level < 2
union
select * from registry where user_id in (implode(',' , $family_array) ) && level < 3
有没有办法在不使用联合的情况下以某种方式做到这一点?