Prefijo Sustantivo Prefijo Sustantivo - 8 days ago 5
MySQL Question

mysql column alias not working, have to create an empty concatenation to make it work

if i do:

SELECT PEvent.publicID AS 'ID'...


Results come as "publicID" not as "ID"

to make it work i have to do:

SELECT concat(PEvent.publicID, '') AS 'ID'


why?

<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
maxActive="10" maxIdle="3" maxWait="1000" type="javax.sql.DataSource"
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
maxActive="10" maxIdle="3" maxWait="1000" type="javax.sql.DataSource"
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
maxActive="10" maxIdle="3" maxWait="1000" type="javax.sql.DataSource"
<Resource auth="Container" driverClassName="com.mysql.jdbc.Driver"
maxActive="10" maxIdle="3" maxWait="1000" type="javax.sql.DataSource"


a very bad thing that something as simple as a column alias does not work...

Answer

It works fine for me when I tested this from my ubuntu mysql command line, and MySQL Workbench for Windows. I figured it might be a jdbc thing, and searched around. MySQL doesn't consider this as a bug.

http://bugs.mysql.com/bug.php?id=21596

From the comment on the BZ,

This is a change required for JDBC-compliance. RSMD.getColumnName() is required to return the actual column name. Aliases are returned via RSMD.getColumnLabel().

If you want the older non-compliant behavior from Connector/J 3.1, use the "useOldAliasMetadataBehavior" configuration parameter present in the 5.0 nightly builds, and set it to "true".

Comments