pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
All columns from table in a joined query
3+ messages / 3 participants
[nested] [flat]

* All columns from table in a joined query
@ 2006-08-23 19:14 MHahn@seeandswim.com
  2006-08-23 19:44 ` Re: All columns from table in a joined query Sumeet <asumeet@gmail.com>
  2006-08-23 21:26 ` Re: All columns from table in a joined query Tom Lane <tgl@sss.pgh.pa.us>
  0 siblings, 2 replies; 3+ messages in thread

From: MHahn@seeandswim.com @ 2006-08-23 19:14 UTC (permalink / raw)
  To: pgsql-sql

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?



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: All columns from table in a joined query
  2006-08-23 19:14 All columns from table in a joined query MHahn@seeandswim.com
@ 2006-08-23 19:44 ` Sumeet <asumeet@gmail.com>
  1 sibling, 0 replies; 3+ messages in thread

From: Sumeet @ 2006-08-23 19:44 UTC (permalink / raw)
  To: MHahn@seeandswim.com <MHahn@seeandswim.com>; +Cc: 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@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.

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: All columns from table in a joined query
  2006-08-23 19:14 All columns from table in a joined query MHahn@seeandswim.com
@ 2006-08-23 21:26 ` Tom Lane <tgl@sss.pgh.pa.us>
  1 sibling, 0 replies; 3+ messages in thread

From: Tom Lane @ 2006-08-23 21:26 UTC (permalink / raw)
  To: MHahn@seeandswim.com; +Cc: pgsql-sql

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 group by 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



^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2006-08-23 21:26 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2006-08-23 19:14 All columns from table in a joined query MHahn@seeandswim.com
2006-08-23 19:44 ` Sumeet <asumeet@gmail.com>
2006-08-23 21:26 ` Tom Lane <tgl@sss.pgh.pa.us>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox