-1

Please tell me that why am i getting error and what should i do to get result.

Tables in my database

+--------------------+
| Tables_in_practice |
+--------------------+
| employee           |
| employee_duplicate |
| employee_record    |
+--------------------+

3 rows in set (0.00 sec)

QUERY

select *
into employee_duplicate
from employee;

ERROR 1327 (42000): Undeclared variable: employee_duplicate

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786
  • To format the table/code/error correctly, please add **4 leading** space to each line of the table. Thanks! –  Nov 11 '17 at 14:03
  • Possible duplicate of [SELECT INTO and "Undeclared variable" error](https://stackoverflow.com/questions/2949653/select-into-and-undeclared-variable-error) – CBroe Nov 11 '17 at 14:06
  • Or https://stackoverflow.com/questions/28690447/mysql-error-1327-when-doing-a-into-from – CBroe Nov 11 '17 at 14:07

1 Answers1

0

In MySQL, you cannot set the entire row to a variable. Perhaps you just want to return the column:

select employee_duplicate
from employee;

If you want to set a variable, you can do:

select @employee_duplicate := employee_duplicate
from employee;

Although you can use into, most people find the := syntax simpler to follow and to write.

Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786