如何按
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
我要显示内容菜单
Ex.
如何查询?
如果你想有无限的子菜单,用PHP循环可能更容易。
制作2级菜单还是很容易的,eg
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
按 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