萌萌小羽 2021-11-26 19:32 采纳率: 66.7%
浏览 82
已结题

mysql书写sql查询多级菜单

img


这样的一个数据库内容。表名operation
请问如何书写sql语句能展示出这种效果

img

我直接用select * from operation查出来的效果是这样的

img

他的父类表应该怎么实现。

王浩这个人名是在user表里

img

  • 写回答

1条回答 默认 最新

  • CSDN专家-sinJack 2021-11-26 19:36
    关注

    就涉及到一张表吗?关联关系是什么。

    select o.*,u.realname,(select operation_name from operation where o.parent_id=operation_no  limit 1) 父菜单 
    from 
    operation o left join user u 
    on o.created=u.username 
    
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论 编辑记录

报告相同问题?

问题事件

  • 系统已结题 12月4日
  • 已采纳回答 11月26日
  • 创建了问题 11月26日