Table Alias

Поиск
Список
Период
Сортировка
От Darrin Ladd
Тема Table Alias
Дата
Msg-id F311mkQSCe837g7RFlz00002825@hotmail.com
обсуждение исходный текст
Ответы Re: Table Alias  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Список 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.


В списке pgsql-general по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: 7.1 Release Date
Следующее
От: Tom Lane
Дата:
Сообщение: Re: 7.1 Release Date