方案:通过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;

 

相关文章:

  • 2022-12-23
  • 2021-12-06
  • 2021-12-02
  • 2021-11-03
  • 2022-12-23
  • 2021-06-19
  • 2022-12-23
  • 2022-02-27
猜你喜欢
  • 2022-02-26
  • 2022-01-01
  • 2021-11-29
  • 2021-09-19
  • 2021-12-06
  • 2022-02-21
  • 2022-12-23
相关资源
相似解决方案