Hi ich habe folgende MySQL Abfrage für ein Nested Set:
die klappt auch wunderbar, nun möchte ich aber das nur die ersten 2 Level ausgegeben werden, sprich Level 1 und 0.
ich habs mit
versucht jedoch krieg ich immer folgende Fehlermeldung:
#1064 - 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 'GROUP BY n.id
ORDER BY n.lft
LIMIT 0, 30' at line 8
Ich find einfach keine passende Lösung, vllt. könnt ihr mir ja weiter helfen
PHP:
SELECT n.id, n.name,
round((n.rgt-n.lft-1)/2,0) AS counter,
count(*)-1+(n.lft>1) AS level
FROM menu n, menu p
WHERE n.lft BETWEEN p.lft AND p.rgt AND (p.id != n.id OR n.lft = 1)
GROUP BY n.id
ORDER BY n.lft
ich habs mit
PHP:
SELECT n.id, n.name,
round((n.rgt-n.lft-1)/2,0) AS counter,
count(*)-1+(n.lft>1) AS level
FROM menu n, menu p
WHERE n.lft BETWEEN p.lft AND p.rgt AND (p.id != n.id OR n.lft = 1)
AND ((count(*)-1+(n.lft>1) < 1)
GROUP BY n.id
ORDER BY n.lft
#1064 - 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 'GROUP BY n.id
ORDER BY n.lft
LIMIT 0, 30' at line 8
Ich find einfach keine passende Lösung, vllt. könnt ihr mir ja weiter helfen