"distinct" on the email addresses, I would UNION all three queries, with
just the emailaddresses, and wrap them in a subquery that would just do
distinct. Then you have the unique emailaddresses, then join that to a
union of all name+extra information. Some fairly complicated sql-ing,
but not rocket science.
--
Hugo Ahlenius
-------------------------------------------------------------
Hugo Ahlenius E-Mail: [EMAIL PROTECTED]
Project Officer Phone: +46 8 230460
UNEP GRID-Arendal Fax: +46 8 230441
Stockholm Office Mobile: +46 733 467111
WWW: http://www.grida.no
-------------------------------------------------------------
| -----Original Message-----
| From: Michael Kear [mailto:[EMAIL PROTECTED]
| Sent: Saturday, May 29, 2004 21:53
| To: CF-Talk
| Subject: De-Duping from 3 queries
|
| I'm writing an emailing application and we're going to be
| selecting our addresses from 3 different subscriber tables,
| based on a whole bunch of
| criteria. I want to merge the 3 queries from the tables
| into one, then
| de-dup so we only send one email to each subscriber.
|
|
|
| Is the following the best process to do this?
|
|
|
| [A] Select the addresses from each table, based on criteria
| related to that table into Qsubscribers, Qmembers, QSeminarAttendees
|
| [B] Create a new query (QTempQuery) in memory, and loop
| through each of the first queries, inserting the records into
| the new query.
|
| [C] De-dup QTempQuery by using QueryofaQuery to select DISTINCT from
| QTempQuery.
|
|
|
| Is there a better way to do it? Seems like a lot of stuff
| going on in memory without anything being written off to disk
| at all. At the moment there will be about 2500 records I
| guess but if it gets too big I might run out of memory mightn't I?
|
|
|
| And what's the SQL to use emailaddress as the key for SELECT
| DISTINCT, but still to select all the other fields in the
| query? (the query has fields called emailaddress,
| firstname, lastname, emailsentYN)
|
|
|
|
|
| Cheers
|
| Mike Kear
|
| AFP Webworks
|
| Windsor, NSW, Australia
|
| http://afpwebworks.com
|
|
|
|
|
|
|
[Todays Threads] [This Message] [Subscription] [Fast Unsubscribe] [User Settings]

