sql语句查询菜单结果成 树状图类型

select * from
(
select 
	pid,id,name,url,concat(id,":") idOrder
from menu
where 
	pid=0 and
	status_id=0 
union

select 
	pid,id,concat("          ",name),url,concat(pid,":",id )
from menu
where
	status_id=0
	and pid in (
		select 
			id
		from menu
		where 
			pid=0 and status_id=0 
	)
) t

order by idOrder
	

  

猜你喜欢

转载自www.cnblogs.com/ynhk/p/10310784.html