Uploaded image for project: 'MariaDB Server'
  1. MariaDB Server
  2. MDEV-19421

Basic 3-way join queries are not parsed

    XMLWordPrintable

Details

    Description

      The following simple join

      select * from t1 join t2 join t3 on t2.a=t3.a on t1.a=t2.a;
      

      over tables t1,t2,t3

      create table t1 (a int); 
      insert into t1 values (7), (2), (9);
      create table t2 (a int);
      insert into t2 values (5), (1), (7);
      create table t3 (a int);
      insert into t3 values (2), (7), (3); 
      

      cannot be parsed in MariaDB 10.4:

      MariaDB [test]> select * from t1 join t2 join t3 on t2.a=t3.a on t1.a=t2.a;
      ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'on t1.a=t2.a' at line 1
      

      MySQL 8.0 handles this query properly:

      mysql> select * from t1 join t2 join t3 on t2.a=t3.a on t1.a=t2.a;
      +------+------+------+
      | a    | a    | a    |
      +------+------+------+
      |    7 |    7 |    7 |
      +------+------+------+
      

      This basic valid query also returns syntax error message:

      select * from t1 join t2 left join t3 on t2.a=t3.a on t1.a=t2.a;
      

      Attachments

        Issue Links

          Activity

            People

              igor Igor Babaev
              igor Igor Babaev
              Votes:
              1 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Git Integration

                  Error rendering 'com.xiplink.jira.git.jira_git_plugin:git-issue-webpanel'. Please contact your Jira administrators.