Forum Moderators: coopster

Message Too Old, No Replies

Error on MySQL Copy

         

PaulPA

1:27 pm on Oct 4, 2008 (gmt 0)

10+ Year Member



I'm trying to copy information from one field to another in two different tables in a MySQL DB. The fields have the same names and the table need to be matched on fields that have the same names. The statement I've been trying is:

INSERT INTO table1 (fld_A) SELECT table2.fld_A FROM table2 WHERE table1.fld_B = table2.fld_B

The error shows that it is not picking up the table1 in the WHERE clause.

dublinmike

1:42 pm on Oct 4, 2008 (gmt 0)

10+ Year Member



You have to include table 1 in the from clause, e.g. INSERT INTO table1 (fld_A) SELECT table2.fld_A FROM table1, table2 WHERE table1.fld_B = table2.fld_B

PaulPA

6:45 pm on Oct 4, 2008 (gmt 0)

10+ Year Member



Right - must have had brain lock! Thanks