首页 > 代码库 > 二级菜单通过一个ID查找父级ID

二级菜单通过一个ID查找父级ID

select `id`,`name`,`pid` AS `q_pid`,(select id  From qiyu_gift_category where id = q_pid ) as root_id from qiyu_gift_category WHERE id = 1



SELECT `id` FROM `qiyu_gift_category` WHERE id = (SELECT pid FROM qiyu_gift_category WHERE id = 1) LIMIT 1