如何按groupmenu对数据进行排序?
mysql
SELECT pc.pc_id, pc.pc_icon, pc.pc_parent, pcd.pcd_name, pcd.pcd_id
FROM product_category pc
LEFT JOIN product_category_detail pcd ON pcd.pc_id=pc.pc_id
ORDER BY pc.pc_group, pc.pc_sort, pc.pc_id
我想显示内容菜单
实施例
我如何查询? 谢谢
答案 0 :(得分:0)
如果您想拥有无限的子菜单,可能更容易使用PHP循环。
生成2级菜单仍然很容易,例如
SELECT a.id,
FROM
SELECT pc.pc_id, pc.pc_icon, pc.pc_parent, pcd.pcd_id,
concat(if (pc.pc_parent = 0, '', '- '), pcd.pcd_name) AS pcd_name
FROM product_category AS pc
LEFT JOIN product_category_detail AS pcd ON pcd.pc_id = pc.pc_id
ORDER BY pc.pc_group,pc.pc_sort,pc.pc_id
或者您可以重新设计类别表,以获得简单且无限制的子菜单树:
pc_id
11
1122 -- kid of 11
112233 -- kid of 1122
55
66
6677 -- kid of 66