joining an array with a table or...?

From: Ivan Sergio Borgonovo <mail(at)webthatworks(dot)it>
To: pgsql-general(at)postgresql(dot)org
Subject: joining an array with a table or...?
Date: 2009-10-26 13:15:26
Message-ID: 20091026141526.4d0094ba@dawn.webthatworks.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

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;

Now mails are into a php array and they may be in the range of 5000
but generally less.

The final query will be something like
insert into mailqueue (qid, uid, mail, ...) select ...

and since some fields are pseudo random sequences computed from a
serial, it would be "clean" to do it just in one query.

Any clean technique?

thanks

--
Ivan Sergio Borgonovo
http://www.webthatworks.it

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Raymond O'Donnell 2009-10-26 14:12:10 Re: [ANNOUNCE] PGDay.EU 2009 - approaching fast!
Previous Message Radcon Entec 2009-10-26 12:48:42 Logging statements with errors in PostgreSQL 8.1