Quantcast
Viewing all articles
Browse latest Browse all 207

RECURSIVE CTE with INNER JOIN - Syntax Error

Can anyone help debug this less than informative error.

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 cte AS (SELECT initial_cg.FROM django_input_' at line 1*

This is with MySQL version 5.7

WITH RECURSIVE cte AS (    SELECT initial_cg.*    FROM django_input_collection_conditiongroup AS initial_cg    WHERE initial_cg.id = 163    UNION ALL    SELECT rec_cg.*    FROM django_input_collection_conditiongroup AS rec_cg, cte AS rec_cte        INNER JOIN django_input_collection_conditiongroup_child_groups ON (             rec_cg.id = django_input_collection_conditiongroup_child_groups.to_conditiongroup_id        )        WHERE django_input_collection_conditiongroup_child_groups.from_conditiongroup_id = rec_cte.id    )SELECT * FROM cte;

FWIW Here is my Table Syntax.

CREATE TABLE django_input_collection_conditiongroup(    id               bigint auto_increment        primary key,    nickname         varchar(100) null,    constraint nickname        unique (nickname));CREATE TABLE django_input_collection_conditiongroup_child_groups(    id                     int auto_increment        primary key,    from_conditiongroup_id bigint not null,    to_conditiongroup_id   bigint not null,    constraint django_input_collection__from_conditiongroup_id_t_68bd6f96_uniq        unique (from_conditiongroup_id, to_conditiongroup_id));

Viewing all articles
Browse latest Browse all 207

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>