select t1.id, t1.name, @FartherId = t1.FartherID
from 信息表 t1
left join 菜單表 t2 on t1.id = t2.id
where t2.id = 'idnumber'while isnull(@Fartherid,'') <> ''
begin
--顯示上級id
select t1.id, t1.name, @FartherId = t1.FartherID
from 信息表 t1
left join 菜單表 t2 on t1.id = t2.id
where t2.id = FartherId end
from 信息表 t1
left join 菜單表 t2 on t1.id = t2.id
where t2.id = 'idnumber'while isnull(@Fartherid,'') <> ''
begin
--顯示上級id
select t1.id, t1.name, @FartherId = t1.FartherID
from 信息表 t1
left join 菜單表 t2 on t1.id = t2.id
where t2.id = FartherId end
--------------------------------------
id name ji followid
message
--------------------------------------
id menuid
name是菜单名,ji表示第几级菜单,followid是他上一级菜单的id,message的menuid是他对应的菜单的id号,第一次画不知道画的对不对.