Table Alias

From: "Darrin Ladd" <darrin_ladd(at)hotmail(dot)com>
To: pgsql-general(at)postgreSQL(dot)org
Subject: Table Alias
Date: 2000-08-29 19:03:08
Message-ID: F311mkQSCe837g7RFlz00002825@hotmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Through the help of some inexperienced embedded SQL coders I stubled across
a strang Postgres quirk. I am wondering if this is normal or if I have
configured something incorrectly. Here's the situation...

The following two selects return very different values:

select b.name from foo f, bar b
where f.foo_id = 1
and f.bar_id = b.bar_id;

select bar.name from foo f, bar b
where f.foo_id = 1
and f.bar_id = b.bar_id;

The first returns the rows in the name column of bar that have the same
bar_id as the foo record with foo_id = 1. (Correct)

The second returns all rows in the name column of the bar table. (?)

I am quite aware that if you declare an alias for a table that you should
use it, but I am very surprised that the select becomes unqualified if you
mistakenly use the full table name. Is this normal behavior?

Thanks!
Darrin
_________________________________________________________________________
Get Your Private, Free E-mail from MSN Hotmail at http://www.hotmail.com.

Share information about yourself, create your own public profile at
http://profiles.msn.com.

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adam Lang 2000-08-29 19:06:01 Re: SQL scripts - sequences
Previous Message Brook Milligan 2000-08-29 19:02:14 Re: 7.1 Release Date