title: How to find Parents and Children in a same table
body: <p>I need to find parents and children in the below table. I tried with below query. But it throws the error </p>
  
  <blockquote>
    <p>[Err] 1235 - This version of MariaDB doesn't yet support 'LIMIT &amp;
    IN/ALL/ANY/SOME subquery</p>
  </blockquote>
  
  <p>I need to find all parents until it reply null. Please help me to find that.</p>
  
  <pre><code>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
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/2tGrH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2tGrH.png" alt="enter image description here"></a></p>
  
  <p>` </p>