On Sat, 28 Feb 2004 11:52:03 +0100, Jakub Adamek <[EMAIL PROTECTED]> wrote:
> Is it really so that some database server returns a result set with two
> same column names? Seems very strange. And the lovely SQLite 3.0.8
> didn't do such things ...

PostgreSQL, which holds closer to the SQL spec than any other DB I'm
aware of, refuses this syntax:

    SELECT * FROM a INNER JOIN b;

You are depending on implicit join syntax that I believe is illegal in
SQL.  The fact that it happens to work doesn't make that a good idea. 
If you are explicit in the join:

petrilli=# SELECT * FROM a, b WHERE a.id = b.id;
 id | x | id | y 
----+---+----+---
  1 | 1 |  1 | 2


As you'll notice, it returns both id columns, because you selected ALL
columns.  This is the correct behavior.  In this case, you've simply
chosen the wrong behavior.  As several other people have commented,
you should, in all join cases, explictely call out all columns that
you are interested in:

petrilli=# SELECT a.id, x, y FROM a, b WHERE a.id = b.id;
 id | x | y 
----+---+---
  1 | 1 | 2

Good luck.

Chris
-- 
| Christopher Petrilli
| [EMAIL PROTECTED]

Reply via email to