mysql union 和 left join 结合查询用法

union 和 left join 结合查询用法

SELECT 
u.nickname,z.group_comming_type,z.id,z.user_id,z.title,z.create_time
from 
((SELECT id,user_id,title,create_time,1 as group_comming_type FROM `group_comming_eat` WHERE status = 1) 
union 
(SELECT id,user_id,coin as title,create_time,2 as group_comming_type FROM `qxx_user_extend` WHERE status = 1)) 
as z left join user as u on z.user_id = u.id  where u.id = 277  order by z.create_time DESC LIMIT 0,10 ;

 

posted @ 2018-06-12 09:23  一个人的孤独自白  阅读(2483)  评论(0编辑  收藏  举报