Re: Anyone knows what's wrong with this INSERT sentence?

2001-07-23 Thread Prune



Martin Cabrera Diaubalick wrote:

> Hello all,
> 
> I have this two tables : table1,table2 . I would like to include all emails from 
>table2 into table1 removing duplicates.
>  
> INSERT INTO table1 (email) SELECT  email from table2 where table1.email <> 
>table2.email;
> 
> MYSQL says: ERROR 1109: Unknown table 'table1' in where clause
> 
> Both tables exist, what's wrong?
> 
> TIA
> 

Hi

First, select "FROM table1, table2" if you want to do a join.
Then your where close will not work with "<>" (I think).

try something like :

insert into table1 select distinct email from table2

which will do exactly what you want.

Remember to check the mysql doc (references) to learn how to use SQL.

Cheers,

Prune

-- 
- le Centre - 
a Mad Cow Tribe product

(Very uncommon, but we should please everybody anyway, even disturbed minds)


-
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




Re: Anyone knows what's wrong with this INSERT sentence?

2001-07-20 Thread Werner Stuerenburg

I don't investigate the error -- why don't you put a unique index
on email? That's how you get what you want.


> I have this two tables : table1,table2 . I would like to include all emails from 
>table2 into table1 removing duplicates.
 
> INSERT INTO table1 (email) SELECT  email from table2 where table1.email <> 
>table2.email;

> MYSQL says: ERROR 1109: Unknown table 'table1' in where clause

> Both tables exist, what's wrong?




-- 
Herzlich
Werner Stuerenburg

_
ISIS Verlag, Teut 3, D-32683 Barntrup-Alverdissen
Tel 0(049) 5224-997 407 ยท Fax 0(049) 5224-997 409
http://pferdezeitung.de



-
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




SV: Anyone knows what's wrong with this INSERT sentence?

2001-07-20 Thread Johan Nilsson

INSERT INTO table1 (email) 
SELECT email FROM table1, table2 WHERE table1.email <> table2.email;

the select is a "new" query, you have to join table1 and table2...

Regards,
Johan Nilsson
Software Developer
BeCon Mobile Internet AB, Sweden
Web: http://www.beconmobile.com
E-Mail: [EMAIL PROTECTED]
Office: +46 457 44184
Cellular: +46 709 798897

> -Ursprungligt meddelande-
> Fran: Martin Cabrera Diaubalick [mailto:[EMAIL PROTECTED]]
> Skickat: den 20 juli 2001 13:14
> Till: [EMAIL PROTECTED]
> Kopia: [EMAIL PROTECTED]
> Amne: Anyone knows what's wrong with this INSERT sentence?
> 
> 
> Hello all,
> 
> I have this two tables : table1,table2 . I would like to include 
> all emails from table2 into table1 removing duplicates.
>  
> INSERT INTO table1 (email) SELECT  email from table2 where 
> table1.email <> table2.email;
> 
> MYSQL says: ERROR 1109: Unknown table 'table1' in where clause
> 
> Both tables exist, what's wrong?
> 
> TIA
> 
> Regards
> 
> 
> 
> -
> 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




Anyone knows what's wrong with this INSERT sentence?

2001-07-20 Thread Martin Cabrera Diaubalick

Hello all,

I have this two tables : table1,table2 . I would like to include all emails from 
table2 into table1 removing duplicates.
 
INSERT INTO table1 (email) SELECT  email from table2 where table1.email <> 
table2.email;

MYSQL says: ERROR 1109: Unknown table 'table1' in where clause

Both tables exist, what's wrong?

TIA

Regards



-
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