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.