Duplicate column name error

242 views
Skip to first unread message

Serg

unread,
Feb 16, 2011, 7:01:52 AM2/16/11
to H2 Database
When I trying execute the query below I get the following error:
“Duplicate column name "DEPARTMENTID" …”

Query:
select * from (select department.*, employee.* from department,
employee where department.departmentid=employee.departmentid)

Tables “department” and “employee” has the common column
“DEPARTMENTID”.
It seems to me that the query is correct, because the inner subquery
works.

Can you support such query?

Sergi Vladykin

unread,
Feb 16, 2011, 7:08:53 AM2/16/11
to H2 Database
Instead of wildcards you should use explicit column list with unique
aliases in your subquery.

Thomas Mueller

unread,
Feb 17, 2011, 12:46:35 AM2/17/11
to h2-da...@googlegroups.com
Hi,

Maybe this will also work in your case, because "natural join" doesn't
duplicate columns:

select * from (select * from department natural join department);

Regards,
Thomas

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

Reply all
Reply to author
Forward
0 new messages