数据库查询

目标: 查询手机注册用户,是否包含关系,明细

  • 只进行手机注册的用户得到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;
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容