Skip site navigation (1) Skip section navigation (2)

Peripheral Links

Header And Logo

PostgreSQL
| The world's most advanced open source database.

Site Navigation

Search archives
  Advanced Search

Re: Join Advice and Assistance


  • From: Rob Sargent <robjsargent(at)gmail(dot)com>
  • To: Gary Chambers <gwchamb(at)gmail(dot)com>
  • Cc: pgsql-sql(at)postgresql(dot)org
  • Subject: Re: Join Advice and Assistance
  • Date: Mon, 22 Feb 2010 10:05:36 -0700
  • Message-id: <4B82B960.3060901@gmail.com> <text/plain>

My mistake.  Should answer these things late at night.

I think you will find that arrays will be your friend[s]

On 02/22/2010 08:51 AM, Gary Chambers wrote:
Rob,

Thanks for the reply...

If you want records for user without email addresses you will need an outer
join on user_emailaddrs

/* untested */
select u.userId, u.lname, u.lastname ,m.startdate, a.emailaddr
from users u
join usermetas m on u.userid = m.userid
left join user_emailaddrs a on m.userid = a.userid

My question was related more toward eliminating the query returning a
record for each record in the one-to-many table.  I see now that I'm
going to have to aggregate the e-mail addresses in order to return a
single row.  Thanks again.

-- Gary Chambers

/* Nothing fancy and nothing Microsoft! */



Home | Main Index | Thread Index

Privacy Policy | About PostgreSQL
Copyright © 1996 – 2012 PostgreSQL Global Development Group