title: how to work with recursive query in MySql?
body: <pre><code>    WITH RECURSIVE transitive_closure(a, b, distance, path_string) AS
  ( SELECT a, b, 1 AS distance,
           a || '.' || b || '.' AS path_string,
           b AS direct_connection
      FROM edges2
     WHERE a = 1 -- set the starting node
  
     UNION ALL
  
    SELECT tc.a, e.b, tc.distance + 1,
           tc.path_string || e.b || '.' AS path_string,
           tc.direct_connection
      FROM edges2 AS e
      JOIN transitive_closure AS tc ON e.a = tc.b
     WHERE tc.path_string NOT LIKE '%' || e.b || '.%'
       AND tc.distance &lt; 3
  )
  SELECT * FROM transitive_closure
  --WHERE b=3  -- set the target node
  ORDER BY a,b,distance
  </code></pre>
  
  <p>how to run this query in MySql?</p>
  
  <p>it will show error message like this:</p>
  
  <pre>
  #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 'RECURSIVE transitive_closure(a, b, distance, path_string) AS ( SELECT a, b, 1 A' at line 1
  </pre>