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

From: Tobias Merler <merlin_at_gmx.net>
Date: 02 Mar 2007 16:07:59 GMT
Message-ID: <45e84bdf$0$23135$9b4e6d93_at_newsspool1.arcor-online.net>

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


id col1 col2

1 aaa ddd
2 bbb eee
3 ccc fff


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 Received on Fri Mar 02 2007 - 17:07:59 CET

Original text of this message