码迷,mamicode.com
首页 > 数据库 > 详细

mysql-模拟全连接处理

时间:2015-09-25 12:54:38      阅读:254      评论: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
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!