根据用户的积分、获取用户的等级,如果用户没有积分,则显示没有等级

--t_user 用户表 t_account 积分表 t_integral 等级表
--根据用户的积分、获取用户的等级,如果用户没有积分,则显示没有等级
select t.id,t.username,ta.userId,
(select
(case
when (ta.pointValue >integral_start && ta.pointValue< integral_end) then rank_name
else null
end
) gradea
from t_integral order by gradea desc limit 0,1
) grade
from t_user t left outer join t_account ta on t.id=ta.userId where t.id='用户id';

原文地址:https://www.cnblogs.com/NiceTime/p/9215394.html