Skip to content

parsing error when associated query contains subquery #1258

Description

@zhaoxugang

Bug Report

Please answer these questions before submitting your issue. Thanks!

  1. What did you do?
    If possible, provide a recipe for reproducing the error.
    CREATE TABLE table1 (
    id int(0) DEFAULT NULL,
    name varchar(255) DEFAULT NULL
    ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

CREATE TABLE table2 (
id int(0) DEFAULT NULL,
name varchar(255) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_bin;

insert into table1(id ,name) values(1,'a');
insert into table2(id ,name) values(1,'a');

select t1.id as i1,t2.id as i2,t3.id as i3
from (select tt.id,tt.name from (select id,name from table1) tt) as t1
LEFT JOIN table1 t2 on t1.name = t2.name
LEFT JOIN table2 t3 on t1.name = t3.name;

select * from temp_v;

  1. What did you expect to see?

------+------+------+
| i1 | i2 | i3 |
+------+------+------+
| 1 | 1 | 1 |
+------+------+------+

  1. What did you see instead?

You have an error in your SQL syntax; check the manual that corresponds to your TiDB version for the right syntax to use line 1 column 103 near "AS t1 LEFT JOIN test.table1 AS t2 ON t1.name=t2.name) LEFT JOIN test.table2 AS t3 ON t1.name=t3.name"

  1. What version of TiDB SQL Parser are you using?
    master

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions