数据库结构列出来会不会出现12个人中有一个的下线 是abcd?

解决方案 »

  1.   

    不明白你的意思,你是说abcd推荐的12人,他们每人推荐的人数都算在abcd帐下?还是每个人直接推荐的人数?如果是第二种情况,则
    sign表中设置(id,user(被荐人),upline(推荐人)然后select count(*) as aabb from sign where upline='abcd'
      

  2.   

    select 
       count(*)
    from
       sign
    where
       upline
    in
    (
        select
            username
        from
            sign
        where
            upline = 'abcd'
    )
      

  3.   

    对于第二级的,可以这样求得:select upline,count(upline) as num from sign where upline in (select user from sign where upline='abcd') group by upline
    如果需要更多的级次,建议增加数据库字段进行标注。