From: | Denis Gasparin <denis(at)edistar(dot)com> |
---|---|
To: | Postgresql General <pgsql-general(at)postgresql(dot)org> |
Subject: | How to address field names in a join query |
Date: | 2001-11-26 09:19:55 |
Message-ID: | 5.1.0.14.0.20011126100831.00aa0050@10.1.1.2 |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)edistar(dot)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 --
---------------------------------------------------------------------------------------
From | Date | Subject | |
---|---|---|---|
Next Message | Tommi Mäkitalo | 2001-11-26 10:04:21 | Re: anyone knows about pam_pgsql ? |
Previous Message | Mike Harding | 2001-11-26 04:54:28 | Strange performance issue |