SELECT INTO and “Undeclared variable” error

前端 未结 10 2207
你的背包
你的背包 2020-11-30 06:58

When I try to execute following query:

SELECT id_subscriber
  INTO newsletter_to_send
  FROM subscribers 

I get an error:

10条回答
  •  挽巷
    挽巷 (楼主)
    2020-11-30 08:05

    MySQL does not support SELECT INTO [table]. It only supports SELECT INTO [variable] and can only do this one variable at a time.

    What you can do, however is use the CREATE TABLE syntax with a SELECT like so:

    CREATE TABLE bar ([column list]) SELECT * FROM foo;
    

提交回复
热议问题