Re: partial JOIN (was: ID column naming convention)
| От | David G. Johnston | 
|---|---|
| Тема | Re: partial JOIN (was: ID column naming convention) | 
| Дата | |
| Msg-id | CAKFQuwamLXJdfRMrjE-Em57o43N6Tzzs-xiLAJGkBZPE81eptA@mail.gmail.com обсуждение исходный текст  | 
		
| Ответ на | partial JOIN (was: ID column naming convention) (Rafal Pietrak <rafal@ztk-rp.eu>) | 
| Ответы | 
                	
            		Re: partial JOIN (was: ID column naming convention)
            		
            		 | 
		
| Список | pgsql-general | 
The only way I know to avoid the column name
duplication is to explicity select column list:
SELECT s.sled,s.length,s....,r.runner as right,r.length as
right_length,r....,l.runner as left,l.length as left_length,l.* FROM
sleds s JOIN runners l ON (s.left=l.runner) JOIN runners r ON
(s.right=r.runner);
.... which is truely overtalkative (and thus obfuscates future query
analize during code maintenance).
Skimmed...
Using explicit column names is expected - using "*" in non-trivial and production queries is not.
You can move the aliases if you would like.
SELECT *
FROM tablea (col1, col2, col4)
JOIN tableb AS tb1 (col1, col3, col5) USING (col1)
JOIN tableb AS tb2
 (col1, col6, col7) USING (col1)
The "USING" clause ensure that only a single "col1" appears in the output.
For all other columns in the duplicate join you need to provide a context-specific alias.
David J.
В списке pgsql-general по дате отправления: