How to address field names in a join query

Поиск
Список
Период
Сортировка
От Denis Gasparin
Тема How to address field names in a join query
Дата
Msg-id 5.1.0.14.0.20011126100831.00aa0050@10.1.1.2
обсуждение исходный текст
Ответы Re: How to address field names in a join query  (Stephan Szabo <sszabo@megazone23.bigpanda.com>)
Re: How to address field names in a join query  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
I have 3 tables with some fields with the same name. For example:

TABLE_A: PR_CODE, DESCRIPTION, IS_VALID

TABLE_B: PR_ST_CODE, PR_CODE, DESCRIPTION

TABLE_C: PR_VD_CODE, PR_CODE, DESCRIPTION

As you see, the DESCRIPTION field is present in all tables.
Now suppose i want to do query like this:

select * from (table_a a inner join table_b b on a.pr_code = b.pr_code) x
inner join table_c c on x.pr_code = c.pr_code

I obtain a resultset with these fields:
PR_CODE | DESCRIPTION | IS_VALID | PR_ST_CODE | DESCRIPTION | PR_VD_CODE |
DESCRIPTION

The question is: how can i refer to the fields DESCRIPTION of each table?

I can refer to table_c DESCRIPTION with c.DESCRIPTION but if i write
x.DESCRIPTION postgresql cannot identy the true field names because
actually there are two x.DESCRIPTION fields... How can i refer to these?

Sorry for the english, I hope you understand anyway...




Doct. Eng. Denis
Gasparin                                             denis@edistar.com
---------------------------------------------------------------------------------------
Programmer & System
Administrator                                http://www.edistar.com
---------------------------------------------------------------------------------------
                              Well alas we've seen it all before
                               Knights in armour, days of yore
                          The same old fears and the same old crimes
                            We haven't changed since ancient times

                               -- Iron Hand -- Dire Straits --
---------------------------------------------------------------------------------------


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

Предыдущее
От: Bruce Momjian
Дата:
Сообщение: Open source companies
Следующее
От: Tommi Mäkitalo
Дата:
Сообщение: Re: anyone knows about pam_pgsql ?