Change in MySQL SQL syntax when use a derived table with parentheses

44 views Asked by At

In my database, I have 2 table like this:

   b (b1 INT)
   c (c1 INT)

In MySQL version 5.7, I can run this query without error

   SELECT * FROM b JOIN ((SELECT * FROM c) tmp) ON b.b1 = tmp.c1

But in MySQL version 8.0, I got this error

   Error Code: 1064. 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 ') ON b.b1 = TMP.c1 LIMIT 0, 1000' at line 1 

When I remove the parentheses like this, it run successful

   SELECT * FROM b JOIN (SELECT * FROM c) tmp ON b.b1 = tmp.c1

I read on this link: https://dev.mysql.com/doc/refman/8.0/en/upgrading-from-previous-series.html#upgrade-sql-changes but I can find any SQL change relate to my problem. So I don't know it's a bug or a change in MySQL syntax. Can anyone help me, please?

0

There are 0 answers