SELECT INTO 和“未声明的变量";错误

2021-11-20 00:00:00 mysql select-into

当我尝试执行以下查询时:

When I try to execute following query:

SELECT id_subscriber
  INTO newsletter_to_send
  FROM subscribers 

我收到一个错误:

#1327 - 未声明的变量:newsletter_to_send

该查询有什么问题?

推荐答案

INSERT ... SELECT

http://dev.mysql.com/doc/refman/5.1/en/insert-select.html

INSERT INTO newsletter_to_send
SELECT id_subscriber FROM subscribers 

PS:你确定你不需要 WHERE 子句吗?

PS: are you sure you don't need in WHERE clause?

相关文章