Thread: All columns from table in a joined query

All columns from table in a joined query

From
MHahn@seeandswim.com
Date:
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
byschedule.* 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?


Re: All columns from table in a joined query

From
Sumeet
Date:

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@seeandswim.com <MHahn@seeandswim.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@seeandswim.com <MHahn@seeandswim.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.

Re: All columns from table in a joined query

From
Tom Lane
Date:
MHahn@seeandswim.com writes:
> 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
groupby schedule.* order by min(meetingday.date);
 

I think what you're after is

select * from schedule where sessionnumber = 165
order by (select min(meetingday.date) from meetingday         where schedule.id = meetingday.scheduleid);
        regards, tom lane