incubator-empire-db-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rainer Döbele <>
Subject re: UNION and the parentheses
Date Wed, 04 Aug 2010 08:11:13 GMT
Hi exxos,


I need a bit more time to investigate this.

In the meantime I suggest to derive a class from DBCombinedCmd and to override the getSelect(StringBuilder
buf) method.

Then copy the code from the base-class and add the parenthesis.


Afterwards in your client-code you write:

DBCommandExpr myExpr = new DBMyCombinedCmd(cmdLeft, "UNION", cmdRight);





Von: exxos [] 
Gesendet: Dienstag, 3. August 2010 15:18
Betreff: UNION and the parentheses



According to the MySQL's documentation (5.0), if the ORDER BY or the LIMIT clause, are used
with UNION, the "( )" have to be added to each SELECT statements.
"To use an ORDER BY or LIMIT clause to sort or limit the entire UNION result, parenthesize
the individual SELECT statements and place the ORDER BY or LIMIT after the last one."

But empire-db version 2.0.6 produces "<DBCommand> UNION (<DBCommand>) ORDER BY
<DBColumn>" and there is no "( )" to the first SELECT.

But by chance it continues to work with the ORDER BY, but with the keyword LIMIT it stops!

The class in charge to build the UNION command seems to be DBCombinedCmd (line 102 - public
boolean getSelect(StringBuilder buf) )

Could you please advise about a workarround?


View raw message