Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.

SQL Error 1327 Undeclared variable

julioCB's profile image julioCB posted 1 month ago in General Permalink

Hi I'm running the following statement:

SELECT * INTO empl1 FROM empleado WHERE id_dep=1

Where it is supporsed that it will create a new table called empl1, this is to break one table in one more table, when I execute it I get the error message 1327 Undeclared variable.

Thank you

ansgar's profile image ansgar posted 1 month ago Permalink

This syntax is for assigning values to a variable, whereas empl1 is a system variable which you cannot declare. Instead, you could SELECT * INTO @empl1 ... to set a session variable. SELECT @empl1 afterwards will show you the content.

What you want is likely such a script:

CREATE TABLE empl1 LIKE empl;
INSERT INTO empl1 SELECT * FROM empl;

Please login to leave a reply, or register at first.




Ads were blocked - no problem. But keep in mind that developing HeidiSQL, user support and hosting takes time and money. You may want to send a donation instead.