I am a MSSQL user and now I am converting my database to MySQL. I am writing the following query in MySQL:
select * into new_tbl from tbl
And I get the following error
Error : Undeclared variable new_tbl
How such a query should be properly written in MySQL?
This question is related to
mysql
sql
sql-server
Use the CREATE TABLE SELECT syntax.
http://dev.mysql.com/doc/refman/5.0/en/create-table-select.html
CREATE TABLE new_tbl SELECT * FROM orig_tbl;
In MySQL, It should be like this
INSERT INTO this_table_archive (col1, col2, ..., coln)
SELECT col1, col2, ..., coln
FROM this_table
WHERE entry_date < '2011-01-01 00:00:00';
Source: Stackoverflow.com