Re: getting column names

From: "Armand Pirvu (home)" <armand(dot)pirvu(at)gmail(dot)com>
To: "David G(dot) Johnston" <david(dot)g(dot)johnston(at)gmail(dot)com>
Cc: "pgsql-general(at)postgresql(dot)org" <pgsql-general(at)postgresql(dot)org>
Subject: Re: getting column names
Date: 2017-04-04 22:13:39
Message-ID: A3437359-9EEC-49A3-95F7-E00C86E0BAB1@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Thanks David

Worked like a charm and results are correct

Armand

On Apr 4, 2017, at 5:00 PM, David G. Johnston <david(dot)g(dot)johnston(at)gmail(dot)com> wrote:

> On Tue, Apr 4, 2017 at 2:51 PM, Armand Pirvu (home) <armand(dot)pirvu(at)gmail(dot)com> wrote:
>
> But if I join back to foo1 like below I get
>
> select a.audit_id, a.table_name, b[1],b[2]
> from
> foo1 a,
> (select
> array(
> select
> column_name::text from
> information_schema.columns
> where
> table_name=a.table_name
> and
> (
> column_name like '%add_by%'
> or
> column_name like '%add_date%'
> )) b) as foo
> ;
>
> ERROR: invalid reference to FROM-clause entry for table "a"
> LINE 10: table_name=a.table_name
> ^
> HINT: There is an entry for table "a", but it cannot be referenced from this part of the query.
>
> ​​https://www.postgresql.org/docs/9.6/static/sql-select.html​
> ​
> ​Adding LATERAL before the second "from_item" should get rid of the error - whether it results in a working and/or correct query I don't know.​
>
> David J.
>

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2017-04-04 23:55:02 Re: keeping WAL after dropping replication slots
Previous Message Tom Lane 2017-04-04 22:06:38 Re: Unexpected interval comparison