Well, I think I got it figured out. I am using PHP, and thought I could lick
it with just one query...not so. I guess nested selects can be done in
mssql. Anyway, here is what I did...basically:

SELECT tableA.email FROM tableA,tableB WHERE tableA.email = tableB.email;
Loaded that into an array[email]
Looped
DELETE FROM tableA WHERE email LIKE 'array[email]';
Then
SELECT email FROM tableA; # into another array[email]
Then
Looped
INSERT INTO tableB (id, email) VALUES('','array[email]');

That should do it I think

Thanks for the help though...now I know you can't do nested selects :\

- randy
=============================
r a n d y / sesser at mac.com

> From: "Rolf Hopkins" <[EMAIL PROTECTED]>
> Date: Fri, 6 Jul 2001 13:57:27 +0800
> To: "{ randy }" <[EMAIL PROTECTED]>, "MySQL" <[EMAIL PROTECTED]>
> Subject: Re: Syntax question for a beginner..
> 
> Even if sub-selects were available in MySQL (which they're not), that query
> would still not work as it will only select the values that are unique to
> tableA.
> 
> What you would be looking at is something like:
> 
> SELECT email
> FROM tableA
> UNION
> SELECT email
> FROM tableB
> 
> But unfortunately, UNION is not available yet either.  The next best thing
> that I can think of is to create a temporary table with the email column
> having a unique index and first add the contents of tableA and then tableB.
> Finally, you can then retrieve all values from the temporary table which
> contains all values from both tableA and tableB, without the duplicates.
> 
> ----- Original Message -----
> From: "{ randy }" <[EMAIL PROTECTED]>
> To: "MySQL" <[EMAIL PROTECTED]>
> Sent: Friday, July 06, 2001 12:28
> Subject: Syntax question for a beginner..
> 
> 
>> Alright, I am about to pull my hair out.
>> 
>> I have 2 tables. Each have a column 'email' that are unique. Some of the
>> records in both tables are duplicates and I want to combine the two tables
>> into one with out bringing in the duplicates. So...
>> 
>> I have this statement:
>> Mysql> SELECT email FROM tableA WHERE NOT (email IN(SELECT email FROM
>> tableB));
>> 
>> Now, this gives me an error at the second SELECT. I have been trying
>> different ways, but no go. I got the general syntax from a friend, but I
>> could not get it to work. Is my syntax just wrong?
>> 
>> mysql  Ver 11.13 Distrib 3.23.36, for -freebsd4.3 (i386)
>> 
>> Any help would be appreciated,
>> - randy
>> 
>> 
>> P.S.
>> Fist time poster, first time lister :)
>> =============================
>> r a n d y / sesser at mac.com
>> 
>> 
>> ---------------------------------------------------------------------
>> Before posting, please check:
>>    http://www.mysql.com/manual.php   (the manual)
>>    http://lists.mysql.com/           (the list archive)
>> 
>> To request this thread, e-mail <[EMAIL PROTECTED]>
>> To unsubscribe, e-mail
> <[EMAIL PROTECTED]>
>> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php
> 


---------------------------------------------------------------------
Before posting, please check:
   http://www.mysql.com/manual.php   (the manual)
   http://lists.mysql.com/           (the list archive)

To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php

Reply via email to