Hello,

I would like to handle result sets with duplicate column names by
using resultSet.getXXX("tableAlias.column"). This seems to work with
MySQL but not with H2:

CREATE TABLE users (
  id int NOT NULL AUTO_INCREMENT,
  name varchar(255) NOT NULL,
  PRIMARY KEY (id)
)

INSERT INTO users VALUES(1,'user 1')
INSERT INTO users VALUES(2,'user 2')

SELECT u.*,u2.* FROM users u, users u2 WHERE u.id=1 AND u2.id=2

With MySQL:
resultSet.getObject("u.id") returns 1
resultSet.getObject("u.name") returns "user 1"
resultSet.getObject("u2.id") returns 2
resultSet.getObject("u2.name") returns "user 2"

With H2 1.3.161:
throws a SQLException 'column XXX not found' for each call.

I'm not sure of what the JDBC specs say in such a case. All that I can
say is that MySQL 5.1 (+Connect/J 5.1.18) and H2 1.3.161 behave
differently.

Of course I know I can set an alias in SQL for each selected column
but this would be very tedious.

Any idea?

Boris.

-- 
You received this message because you are subscribed to the Google Groups "H2 
Database" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/h2-database?hl=en.

Reply via email to