Re: Which column is taken in JOIN with multiple columns and different content ?



On Mar 3, 4:38 am, Digeratus 2006 <digeratus2...@xxxxxxxxxxxxxxxxxxxx>
wrote:
mer...@xxxxxxx (Tobias Merler) wrote innews:45e84bdf$0$23135$9b4e6d93@xxxxxxxxxxxxxxxxxxxxxxxxxxx:



Assume I join two tables.
Both of these tables contain a column with name "col1". This column
ist not he primary key. However this column contains different values
which value is taken ?

Lets see the following example:

Select *
FROM tablea a, tableb b
Where a.id = b.id

tablea:

id col1 col2

1 aaa ddd
2 bbb eee
3 ccc fff

tableb:

id col1 col3

1 zzz uuu
2 xxx vvv
3 yyy www

The result table will look like:

id col1 col2 col3

1 ??? ddd uuu
2 ??? eee vvv
3 ??? fff www

Which values will be for the questions marks ?

Ok, I know the data model is not perfect and the two tables could be
merged. But keep in mind that the sample is only a simplified version
of a more complex SQL statement. So lets concentrate on my question.

Thank you

Toby

Toby,
Because of the conflicting column names, Oracle would give you a syntax
error, try it. The syntax in Oracle would be select a.*, b.*. The
resulting table should be apparent now.

Andy Young

I'm nore puzzled about why anyone would think there might be a
problem. Would you also predict an error from this?

SQL> select deptno, dname, dname from dept;

Perhaps you are thinking of the error you get when a column is
ambiguously defined in a subquery and you then refer to it in the
outer query.


.



Relevant Pages

  • Re: Performance of REGEXP_LIKE vs LIKE?
    ... There are certain situations where the syntax of REGEXP_LIKE ... is cleaner and shorter than the comparable LIKE expression. ... search of a 3 million record table, for a series of text strings. ... How about Oracle Text? ...
    (comp.databases.oracle.misc)
  • Re: Oracle input parameter of type string problem
    ... the syntax of my sproc may not be 100% correct. ... months since I have coded in Oracle and I typed the syntax from memory. ... Gregory A. Beamer ... > With the standard OleDb provider, I believe it is safe to use @Year or? ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: Oracle procedure raises exception but looks to be successful from DBI
    ... is the more desirable syntax for calling oracle procedures. ... because DBI's execute method returned success even though the ... procedure raised an exception. ...
    (perl.dbi.users)
  • Re: How to decode in SQL Server 2005
    ... non-standard, non-portable features such as the join syntax, DECODE, ... NVL even though Oracle has long since supported the ... ISO standard alternatives. ... The main reason is that we use what we know best. ...
    (comp.databases.ms-sqlserver)