Re: All columns from table in a joined query

From: Sumeet <asumeet(at)gmail(dot)com>
To: "MHahn(at)seeandswim(dot)com" <MHahn(at)seeandswim(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: All columns from table in a joined query
Date: 2006-08-23 19:44:35
Message-ID: 7539aebb0608231244n142bb3b4o97f82cb76a4e22ed@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

You need to create a custom aggregate for this

CREATE AGGREGATE array_accum (

sfunc = array_append,

basetype = anyelement,

stype = anyarray,

initcond = '{}'

);

then use the field names in your query like this

select array_to_string(array_accum(field1 || '@' || field2),'#') as
field_alias from table_name

records will be seperated by '#'

hope this helps.

On 8/23/06, MHahn(at)seeandswim(dot)com <MHahn(at)seeandswim(dot)com> wrote:
>
> I've been trying to figure out how to do the following:
>
> Select schedule.* from schedule join meetingday on schedule.id =
> meetingday.scheduleid where sessionnumber = 165 group by schedule.* order
> by min(meetingday.date);
>
> Is this possible in any way, or do I need to list each field of the
> schedule table to get all of them?
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

--
Thanks,
Sumeet Ambre
Masters of Information Science Candidate,
Indiana University.

On 8/23/06, MHahn(at)seeandswim(dot)com <MHahn(at)seeandswim(dot)com> wrote:
>
> I've been trying to figure out how to do the following:
>
> Select schedule.* from schedule join meetingday on schedule.id =
> meetingday.scheduleid where sessionnumber = 165 group by schedule.* order
> by min(meetingday.date);
>
> Is this possible in any way, or do I need to list each field of the
> schedule table to get all of them?
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings
>

--
Thanks,
Sumeet Ambre
Masters of Information Science Candidate,
Indiana University.

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Jim Buttafuoco 2006-08-23 19:56:11 Re: Deleting Functions
Previous Message Scott Petersen 2006-08-23 19:29:12 Deleting Functions