php case when

select
a.openid as openid, sum( a.calorie + b.calorie)
as calorie,
(CASE WHEN a.date > b.date
THEN a.imgurl
ELSE b.imgurl
END) imgurl,
(CASE WHEN a.date > b.date
THEN a.nickname
ELSE b.nickname
END) nickname
from `spinningame` a left join `instructorinfo` b on a.openid = b.openid where a.openid = b.openid group by a.openid;

posted @ 2017-12-25 15:35  SingleShadow  阅读(260)  评论(0编辑  收藏  举报