UNION ALL 分支语句有limit 不加括号报错,是语法限制还是bug?

【 使用环境 】测试环境
【 OB or 其他组件 】OB
【 使用版本 】5.7.25-OceanBase_CE-v4.2.2.0
【问题描述】UNION ALL 分支语句有limit 报错
如下图两个表
image
1、当执行sql为
select * from t1 limit 10 union all select * from t2 limit 10;
提示错误
ERROR 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your OceanBase version for the right syntax to use near ‘union all select * from t2 limit 10’ at line 1

2、当sql语句修改为
(select * from t1 limit 10) union all (select * from t2 limit 10);
即可执行

【复现路径】问题出现前后相关操作

1 个赞

不加()会认为是一条sql。所以会报错

1 个赞

遇到个类似问题 :+1: