美文网首页
数据库查询

数据库查询

作者: 老欧 | 来源:发表于2017-02-09 16:24 被阅读0次

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

  • 只进行手机注册的用户得到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;

相关文章

  • SQL server数据库

    查询数据库 查询所有数据库 exec sp_helpdb; 查询数据库test exec sp_helpdb te...

  • MySQL, SQLite 和 PostgreSQL 关于inf

    显示(查询)所有的数据库 MySQL查询: PostgreSQL查询: 查询当前数据库中所有的表信息 like后可...

  • MongoDB开发之 Shell基本操作

    引子 运行 数据库 查看当前数据库: 选择数据库: 创建 执行插入操作: 查询 查询单条数据: 更新 执行查询操作...

  • 数据库扩展解决方案

    1. 缓存数据库查询 缓存数据库查询是可以处理数据库负载的最简单的改进之一。通常,应用程序将包含少数查询,这些查询...

  • 查看postgres数据库连接数

    查询数据库允许的最大连接数: 查询结果: max_connections1000 查询数据库当前连接数脚本: 查询...

  • kettle 知识

    kettle的正常转换速度 容易产生性能问题的场景 1. 查询类: 数据库查询:数据库查询、数据库连接、插入更新 ...

  • MYSQL 3.语法整理

    数据库数据查询知识 请查询 Mysql 1.数据库基本语法 -- 数据库操作 SHOW DATABASES; --...

  • spring集成mybatis使mybatis一级缓存失效

    使用mybatis查询数据库: spring集成mybatis查询数据库: 总结:spring集成mybatis进...

  • Mysql常用语句

    1.查询数据库所有表信息: 2.查询数据库所有表字段结构: 3.查询数据库所有视图定义: 4.mysql常用函数:

  • 使用SQL查询所有数据库名和表名

    MySQL中查询所有数据库名和表名 1. 查询所有数据库 2. 查询指定数据库中所有表名 3. 查询指定表中的所有...

网友评论

      本文标题:数据库查询

      本文链接:https://www.haomeiwen.com/subject/woavittx.html