Reputation: 22522
I am currently using hsqldb for testing and mysql for production. This combination has worked great for me on every recent project, but I've come across a situation where HSQLDB's syntax/dialect is different from MySQL, and I'm not really sure what the best strategy is to overcome it.
In mysql, you can write a union query like this:
select ...
union
select ...
order by created_on desc
limit 20 offset 0
However, in HSQLDB, it complains that order by
clause has an error.
Is there any way I can write the query so that both databases like the syntax?
Upvotes: 2
Views: 3296
Reputation: 24096
try this:
select * from (
select ...
union
select ...)a
order by a.created_on desc
limit 20 offset 0
Upvotes: 3