我试图从我的数据库中的菜单项列表中的多层菜单中组合在一起。这是我的查询。fl=第一级,sl=第二级,等等。
这是查询:
SELECT name as flName,id AS flId
FROM menu_items AS m1
WHERE parent_id = 0
INNER JOIN (SELECT name AS slName, id AS slId, parent_id AS slPid FROM menu_items)
m2 ON m1.firstLevelId = m2.parent_id
INNER JOIN (SELECT name AS tlName, id AS tlId, parent_id AS tlPid FROM menu_items)
m3 ON m2.id = m3.parent_id
我得到的错误是:
PersistenceException: Query threw SQLException:You have an error in your SQL syntax.
check the manual that corresponds to your MySQL server version for the right syntax to
use near 'INNER JOIN (SELECT name AS slName, id AS slId, parent_id AS slPid FROM
menu_item'
但这对我来说似乎是有效的,我不知道。我很确定我之前已经对子查询进行过连接。我做错了什么吗?