MySQL 在mysql中选择
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/16809393/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
select into in mysql
提问by Mandeep Singh
I am a MSSQL user and now I am converting my database to MySQL. I am writing the following query in MySQL:
我是 MSSQL 用户,现在我正在将我的数据库转换为 MySQL。我正在 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?
如何在 MySQL 中正确编写这样的查询?
回答by Dave K
Use the CREATE TABLE SELECT syntax.
使用 CREATE TABLE SELECT 语法。
http://dev.mysql.com/doc/refman/5.0/en/create-table-select.html
http://dev.mysql.com/doc/refman/5.0/en/create-table-select.html
CREATE TABLE new_tbl SELECT * FROM orig_tbl;
回答by MuhammadHani
In MySQL, It should be like this
在 MySQL 中,它应该是这样的
INSERT INTO this_table_archive (col1, col2, ..., coln)
SELECT col1, col2, ..., coln
FROM this_table
WHERE entry_date < '2011-01-01 00:00:00';

