-
-
Notifications
You must be signed in to change notification settings - Fork 496
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
SQL syntax error while using Limit with UnionAll in MySQL #454
Comments
For ref: https://stackoverflow.com/questions/1415328/combining-union-and-limit-operations-in-mysql-query as a workaround for now, you can wrap the original query in a subquery, it's not identical but same result var query = new Query().From(
new Query("table1").Limit(10).As("sub")
).UnionAll(q => q.From("table2")); |
Hi, @ahmad-moussawi thanks for the above comment it works for me, according to this docs it should give a proper syntax maybe there is an issue with SqlKata. |
Yes indeed |
Why did you close it :-)? |
I am rethinking about this, and concluding that this should be the expected result, since if we are instructing the QueryBuilder to build a wrong query, it should not correct it itself. |
I'm using UnionAll with Limit and using MySQL compiler to get SqlResult, while I'm executing the command it is throwing SQL syntax error.
Below is the code
var query = new Query("table1").UnionAll(q => q.From("table2")).Limit(10); var sql = new MySqlCompiler().Compile(query);
sql result is SELECT * FROM
table1
LIMIT 10 UNION ALL SELECT * FROMtable2
but the syntax should be (SELECT * FROM
table1
LIMIT 10) UNION ALL (SELECT * FROMtable2
)The text was updated successfully, but these errors were encountered: