mysql之上二级

mysql之上二级_第1张图片

#获取会员的上二级
drop view if exists vwMemberL2Parent;

create view vwMemberL2Parent 
as
select m.id,
    m.parent_id,
    m.nickname,
    m.realname,
    m.avatar,
    m.mobile,
    m.invite_merch_id,
    L2.nickname as L2nickname,
    L2.realname as L2realname,
    L2.avatar as L2avatar,
    L2.mobile as L2mobile
from `ims_tycb_xyl_member` as m 
LEFT JOIN `ims_tycb_xyl_member` as L1 on m.parent_id = L1.id
LEFT JOIN `ims_tycb_xyl_member` as L2 on L1.parent_id = L2.id

 

你可能感兴趣的:(mysql之上二级)