union all后面需要是用select查出的子表,不能是直接写一个子表名在那!!!
SELECT
c1,
c2
from t1 where ......
union all
SELECT
c1,
c2
from t2 where ......
-- 正确
SELECT
c1,
c2
from t1 where ......
union all
(
SELECT
c1,
c2
from t2 where ......
) p
-- FAILED: ParseException line 8:0 cannot recognize input near '(' 'SELECT' 'c1' in select clause
SELECT
c1,
c2
from t1 where ......
union all
SELECT
*
from
(
SELECT
c1,
c2
from t2 where ......
) p
-- 正确
以上是在hive下,mysql下大可能也是这样!!
更多推荐
union all的坑, FAILED: ParseException cannot recognize input near ‘(‘ ‘SELECT‘ ‘‘
发布评论