目标: 查询手机注册用户,是否包含关系,明细
- 只进行手机注册的用户得到user_id
- 根据user_id 在user_circle表中查询,有两列数据需要匹配user_id,friend_id
- 根据user_id 在user_coupon表中匹配,user_id
如何获得只有手机号注册的用户
- 在表user_phone中的user_id,去除在user_weixin中包含的user_id
select user_id from user_phone where user_id not in (select user_id from user_weixin);
select user_phone.user_id from user_phone left join user_weixin on user_phone.user_id=user_weixin.`user_id` where user_weixin.user_id is null and user_phone.user_id is not null
匹配
select * from user_circle uc, (select user_id from user_phone where user_id not in (select user_id from user_weixin)) a where a.user_id = uc.user_id;
select * from user_coupon cp, (select user_id from user_phone where user_id not in (select user_id from user_weixin)) a where a.user_id = cp.user_id;