首页 > 数据库技术 > 详细

mysql-模拟全连接处理

时间:2015-09-25 12:52:34      阅读:221      评论:0      收藏:0      [点我收藏+]

方案:通过union连接查询出所有需要的特殊标签,然后在通过left join与union中的结果集做多表比较。

sql 

select t.`code`,a.`count` as count_a,b.`count` as count_b from(
select `code` from tmp_a a
union
select `code`from tmp_b b) t left  join tmp_a a on t.`code`=a.`code` left join tmp_b b on t.`code`=b.`code`;

 两张表

select * from tmp_a;
select * from tmp_b;

 

mysql-模拟全连接处理

原文:http://www.cnblogs.com/hwaggLee/p/4837751.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!