MySQL实战注意事项(一)求交集
2019-06-17 19:06
99 查看
交集
参考链接:mysql取差集、交集、并集
select num FROM( select u.code_sn as id,u.phone_number as num from t1 b left join t2 u on b.from_user=u.code_snwhere b.to_account='1000' and b.json_info like '%09月份%' union all select u.code_sn as id,u.phone_number as num from t1 o left join t2 u on o.buyer_code_sn=u.code_sn where o.seller_account_code_sn='1000' and o.json_info like '%09月份%' )t3 group by num having count(num)=2
还有一种方法是使用外连接,取空值。
参考链接:【Mysql】求两个表(查询结果)的差集
select id FROM usertable LEFT JOIN( select id as i from blog ) as t1 ON usertable.id=t1.i where t1.i IS NULL
相关文章推荐
- 关于MySQL的实战一:基本的注意事项
- 服务端开发指南与最佳实战 | 数据存储技术 | MySQL(04) 索引使用的注意事项
- 最新Linux系统下安装MySql 5.7.17全过程及注意事项
- MySQL索引类型一览 让MySQL高效运行起来 mysql索引注意事项
- MySQL生产库主从重新同步操作注意事项
- Mysql 目录恢复注意事项
- Mysql使用sum函数时的注意事项
- 使用MySQL-Proxy读写分离时的注意事项
- wampserver2.2e-php5.3.13-httpd2.2.22-mysql5.5.24-32b.exe 安装 配置 注意事项
- Mysql注意事项
- linux Mysql 配置一些注意事项
- Mysql主从复制注意事项的讲解
- 【原创】MySql的语法及注意事项
- MySQL索引类型总结和使用技巧以及注意事项
- mysql写存储过程的一些注意事项以及mysql的一些函数
- MySQL中使用外键约束的注意事项
- ubuntu安装Mysql的注意事项
- JDBC &Mysql 批处理注意事项
- Mybatis实战注意事项(五)使用concat函数进行模糊查询
- mysql索引优化的注意事项