1

I am trying to take table backup before making any change, following this link for the query http://www.w3schools.com/sql/sql_select_into.asp . However its not working and throwing error #1327 - Undeclared variable: default_table_backup_31_08_2012. Let me know why it is not working?

phpMyAdmin :Version - 3.4.5.

*NOTE: However I find a method under phpmyadmin , GOTO->Operations and perform the copy but i want to know what actually the mistake in the query and kindly provide a solution in terms of query so that i can use it in general :)

My sql query-

SELECT *
INTO default_table_backup_31_08_2012
FROM default_table
Trialcoder
  • 5,816
  • 9
  • 44
  • 66

2 Answers2

5

As documented under SELECT INTO TABLE:

MySQL Server doesn't support the SELECT ... INTO TABLE Sybase SQL extension. Instead, MySQL Server supports the INSERT INTO ... SELECT standard SQL syntax, which is basically the same thing. See Section 13.2.5.1, “INSERT ... SELECT Syntax”. For example:

INSERT INTO tbl_temp2 (fld_id)
    SELECT tbl_temp1.fld_order_id
    FROM tbl_temp1 WHERE tbl_temp1.fld_order_id > 100;

Alternatively, you can use SELECT ... INTO OUTFILE or CREATE TABLE ... SELECT.

In your case, you probably want:

CREATE TABLE default_table_backup_31_08_2012 SELECT * FROM default_table;
eggyal
  • 122,705
  • 18
  • 212
  • 237
0

mysql does not support select into. please see the link below. SELECT INTO and "Undeclared variable" error. You can create a table CREATE TABLE default_backup

than copy information

INSERT INTO default_backup
SELECT * FROM default;
Community
  • 1
  • 1
delwasaf ewrew
  • 557
  • 1
  • 8
  • 21