-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
[BUG] JSQLParser Version 4.6 : MySQL : ParseException from using ORDER BY with UNION query #1737
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Greetings. Thank you for reporting. The extra brackets around the SELECT `topic`
, `order_0`
FROM ( SELECT `topic` AS `topic`
, `priority` AS `order_0`
FROM table1
GROUP BY `topic`
UNION ALL
SELECT `topic` AS `topic`
, `priority` AS `order_0`
FROM table2
GROUP BY `topic`
ORDER BY `order_0` )
GROUP BY `topic`
ORDER BY `order_0`
; In general, the Parser is not very good with Extra Brackets yet and I recommend to avoid such Extra Brackets where possible. |
The main problem is, that the Parser expected the |
Thanks for the very quick response! I see. For now I will go forward with your suggestion of removing the parentheses since that can be parsed |
SELECT `topic`
, `order_0`
FROM ( SELECT `topic` AS `topic`
, `priority` AS `order_0`
FROM table1
GROUP BY `topic`
UNION ALL (
SELECT `topic` AS `topic`
, `priority` AS `order_0`
FROM table2
GROUP BY `topic`
ORDER BY `order_0` ) )
GROUP BY `topic`
ORDER BY `order_0`
; Illustration where the problem is: |
Duplicate #903 |
I am working on this one. I got this statement parsed already, although at the cost of breaking other statements due to the flawed Bracket implementation. |
Hello, as per the error tracker guidelines I tested the sql statement in the interactive demo page here and was not able to format the query. However, I can execute it in MySql.
Failing SQL Feature:
JSQLParserException
is being thrown from callingCCJSqlParserUtil.parse(sql)
with the sql statement provided below.net.sf.jsqlparser.parser.ParseException: Encountered unexpected token: "ORDER" "ORDER"
SQL Example:
Note that if you do one of the following:
ORDER BY
SELECT
s that getUNION
then this statement can be parsed.
Stack trace:
Software Information:
The text was updated successfully, but these errors were encountered: