Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Ambiguous column names in subselects - how resolve?

Ambiguous column names in subselects - how resolve?

From: cipher <markus.doerschmidt_at_gmail.com>
Date: Mon, 17 Sep 2007 03:55:34 -0700
Message-ID: <1190026534.664647.222360@d55g2000hsg.googlegroups.com>


Hi!

I have two tables "A" and "B". Table A has columns named "a" and "c", table B has "b" and "c". Note, that "c" is in both tables! (In my real application, both tables are more complex and have about 20 columns.)

Oracle has no "LIMIT"-condition like MySQL, so I need subselects as work-around (found at http://addictedtonow.com/archives/84/a-few-oracle-tips/). The SELECT would look like this one:

SELECT *
FROM (
    SELECT ta.*, tb.*, ROWNUM as counter     FROM A ta, B tb
    ORDER BY ta.a
)
WHERE counter BETWEEN 1 AND 25;

In this statement, Oracle reports and "ambiguously defined column", because "c" is in both tables.
What can I do, to resolve this? Is there a possibility to tell Oracle to add prefixes to the column names? (Before you answer, please read the next lines!)
Due to the complexity of the application using the database, renaming of the table columns is no option.
Listing the column names (and specify aliases where required) instead of "*" is also a bad idea, because it make extending database and application more difficult. (I have the same problem for different queries over different tables).

Thanks for any helping hints

Markus Received on Mon Sep 17 2007 - 05:55:34 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US