Re: [SQL] distinguishing identical columns after joins

2011-03-01 Thread Lee Hachadoorian
On 03/01/2011 06:00 PM, Rob Sargent wrote: > > On 03/01/2011 03:13 PM, S G wrote: >> On Tue, Mar 1, 2011 at 2:53 PM, Rob Sargent wrote: >>> >>> On 03/01/2011 12:47 PM, S G wrote: This question is particularly geared towards self-joins, but can apply to any join where the tables involved

Re: [SQL] distinguishing identical columns after joins

2011-03-01 Thread Stephen Cook
In times like these, I usually write a query using information_schema.columns to generate the column list: SELECT ordinal_position, 1 AS table_instance, 'a.' || column_name || ' AS ' || column_name || '_a,' FROMINFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'your_table_her

Re: [SQL] distinguishing identical columns after joins

2011-03-01 Thread Rob Sargent
On 03/01/2011 03:13 PM, S G wrote: > On Tue, Mar 1, 2011 at 2:53 PM, Rob Sargent wrote: >> >> >> On 03/01/2011 12:47 PM, S G wrote: >>> This question is particularly geared towards self-joins, but can apply >>> to any join where the tables involved have any identical column names. >>> Aside fro

Re: [SQL] distinguishing identical columns after joins

2011-03-01 Thread S G
On Tue, Mar 1, 2011 at 2:53 PM, Rob Sargent wrote: > > > On 03/01/2011 12:47 PM, S G wrote: >> This question is particularly geared towards self-joins, but can apply >> to any join where the tables involved have any identical column names. >>  Aside from explicit column references, is there any wa

Re: [SQL] Problem with serial counters

2011-03-01 Thread Richard Huxton
On 24/02/11 21:09, Jacques Lebrun wrote: I guess when I do an insert with all the fields (including the RowId), Postgres does not increment the serial counter. I cannot remove the RowId field from the Insert of my setup script because this setup script is also used by customers using MySQL. Apa

Re: [SQL] distinguishing identical columns after joins

2011-03-01 Thread Rob Sargent
On 03/01/2011 12:47 PM, S G wrote: > This question is particularly geared towards self-joins, but can apply > to any join where the tables involved have any identical column names. > Aside from explicit column references, is there any way to pull all > columns (*) from each table in a join and q

[SQL] distinguishing identical columns after joins

2011-03-01 Thread S G
This question is particularly geared towards self-joins, but can apply to any join where the tables involved have any identical column names. Aside from explicit column references, is there any way to pull all columns (*) from each table in a join and quickly append/prepend some identifier to dist