I need to find parents and children in the below table. I tried with below query. But it throws the error
[Err] 1235 - This version of MariaDB doesn't yet support 'LIMIT & IN/ALL/ANY/SOME subquery
I need to find all parents until it reply null. Please help me to find that.
SELECT id, name
FROM categories
WHERE id IN (SELECT id FROM categories WHERE parentid IS NULL LIMIT 1)
UNION ALL
SELECT cat.id, cat.name
FROM categories as cat,
categories
WHERE categories.id = cat.parentid
`