I am having trouble with SQL that works using interactive or Perl/PHP interfaces,
but fails using JDBC. This seems isolated to queries with ORDER BY in them.
If I use an alias for a column name or a LEFT JOIN with ORDER BY I get an error;
I have tried both the following drivers, org.gjt.mm.mysql.Driver and com.mysql.jdbc.Driver.

General error, message from server: "Unknown column 'copi' in order clause".

If I add the table name to the column name I then get this message;

General error, message from server: "Unknown table 'contracts_copi' in order clause"

Example query below;

SELECT contracts.account_id AS id, contracts_copi.co_pi
FROM contracts
LEFT JOIN contracts_copi ON contracts.account_id=contracts_copi.account_id
ORDER BY co_pi