left join和union结合的用法
子查询union 然后加个括号设置个别名 (union自动去除 重复的 )

 

<pre>
select o.nickName,o.sex,o.province,o.city,from_unixtime(m.time,'%Y-%m-%d %H:%i:%s') as starttime,from_unixtime(z.time,'%Y-%m-%d %H:%i:%s') as endtime,ROUND((z.time-m.time)/60) as haoshifenzhong,from_unixtime(z1.time,'%Y-%m-%d') as choujiangtime from (select openid,time from xintjiashen_zhongjiang2 union select openid,time from xintjiashen_meizhong2) as z left join xintjiashen_my as m on z.openid=m.openid left join xintjiashen_zhongjiang1 as z1 on m.openid=z1.openid left join xintjiashen_oauthinfo as o on m.openid=o.wechatId where z1.prize_id !=8
</pre>

相关文章:

  • 2021-10-19
  • 2021-04-03
  • 2021-12-16
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
  • 2021-12-29
猜你喜欢
  • 2021-11-30
  • 2021-05-29
  • 2021-06-02
  • 2021-05-16
  • 2021-11-09
  • 2021-08-11
  • 2021-11-26
相关资源
相似解决方案