Single Store CTE table does not exist

76 Views Asked by At

I keep on getting the error Error Code: 1146. Table 'cte' doesn't exist. Below is the query. What's causing the error?

WITH cte (tree_id, node_name) AS 
( 
     SELECT tree_id, node_name
     FROM report_tree
     WHERE parent_tree_id IS NULL
     AND report_code = 'CORP'
UNION ALL
     SELECT t2.tree_id, CONCAT (cte.node_name, '-->', t2.node_name )
     FROM cte t1
          JOIN report_tree t2 ON t1.tree_id = t2.parent_tree_id
)
SELECT * FROM cte ORDER BY tree_id;

CTE is supported by SingleStore. I added RECURSIVE after WITH and I am getting a syntax error. I am using MySQL WOrkbench 8.0

0

There are 0 best solutions below