Re: [GENERAL] joining an array with a table or...?

2009-10-27 Thread Merlin Moncure
On Mon, Oct 26, 2009 at 2:48 PM, Ivan Sergio Borgonovo wrote: > On Mon, 26 Oct 2009 14:56:26 -0400 > Merlin Moncure wrote: > >> On Mon, Oct 26, 2009 at 11:05 AM, Ivan Sergio Borgonovo >> wrote: >> > To make it more concrete I came up with: >> > >> > select coalesce(u.mail,j.mail) from ( >> >  se

Re: [GENERAL] joining an array with a table or...?

2009-10-26 Thread Ivan Sergio Borgonovo
On Mon, 26 Oct 2009 14:56:26 -0400 Merlin Moncure wrote: > On Mon, Oct 26, 2009 at 11:05 AM, Ivan Sergio Borgonovo > wrote: > > To make it more concrete I came up with: > > > > select coalesce(u.mail,j.mail) from ( > >  select (array['m...@example1.com','m...@example2.com'])[i] as mail > >   fro

Re: [GENERAL] joining an array with a table or...?

2009-10-26 Thread Merlin Moncure
On Mon, Oct 26, 2009 at 11:05 AM, Ivan Sergio Borgonovo wrote: > To make it more concrete I came up with: > > select coalesce(u.mail,j.mail) from ( >  select (array['m...@example1.com','m...@example2.com'])[i] as mail >   from generate_series(1,2) i) j >   left join users u on upper(u.mail)=upper(

Re: [GENERAL] joining an array with a table or...?

2009-10-26 Thread Ivan Sergio Borgonovo
On Mon, 26 Oct 2009 14:15:26 +0100 Ivan Sergio Borgonovo wrote: > I've a list of emails and a list of users (with emails). > > If the list of emails was already inside a table > > create table mails ( > mail varchar(64) > ); > > create table users ( > name varchar(127), > mail varchar(64)

[GENERAL] joining an array with a table or...?

2009-10-26 Thread Ivan Sergio Borgonovo
I've a list of emails and a list of users (with emails). If the list of emails was already inside a table create table mails ( mail varchar(64) ); create table users ( name varchar(127), mail varchar(64) ); I'd do: select coalesce(u.mail, m.mail) from mails left join users on u.mail=m.mail