参考ページ
を見ながら、自分の環境にて、クエリをしようとしています。
しかし、できないです
sql
1with recursive child (depth, id, parent) as ( 2 select 3 0, 4 tree.id, 5 tree.parent 6 from testlibd.tree 7 where tree.id = 'C' 8 9 union all 10 11 select 12 child.depth + 1, 13 tree.id, 14 tree.parent 15 from testlibd.tree as t, child 16 where t.parent = child.id) 17 18select depth, id, parent from child 19
の6行目にて
SQL
1SQL エラー [1064] [42000]: 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 ')' at line 6
と出てしまいます。
特に、作られたchildテーブルの、データベース名は指定しなくてもよいのか、そもそもどこにあるのか、などがわかっていないです。
原因がご存じの方ございましたら、ご指摘ください。
以下参考情報
mysql Ver 8.0.17 for Win64 on x86_64 (MySQL Community Server - GPL)
回答1件
あなたの回答
tips
プレビュー