Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL ERROR 1327 when doing a INTO FROM

What is the problem with this command.

SELECT *  INTO database2.table2 FROM database1.table1;

It returns this error:

ERROR 1327 (42000): Undeclared variable: database2

The goal is to transfer data in table1 to database2.


2 Answers

select ... into is for storing values in variables. See the documenation for more details. What you need is an insert into .. select ..

insert into database2.table2 (select * from database1.table1)
like image 121
Jens Avatar answered Jan 21 '26 06:01

Jens


Use: CREATE TABLE database2.table2 AS select * from database1.table1;

MySQL probably does not support SELECT ... INTO ... FROM syntax.

like image 20
HGF Avatar answered Jan 21 '26 05:01

HGF



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!