0

这就是插入,选择通常工作的方式(示例来自:https ://stackoverflow.com/a/576442/101055 ):

INSERT INTO new_table (Foo, Bar, Fizz, Buzz)
SELECT Foo, Bar, Fizz, Buzz
FROM initial_table

Fizz但是-如果不在initial_table中,而是一个变量,如何做到这一点@fizz

失败了

INSERT INTO new_table (Foo, Bar, @fizz, Buzz)
SELECT Foo, Bar, Buzz
FROM initial_table

谢谢

4

1 回答 1

2
INSERT INTO new_table (Foo, Bar, Fizz, Buzz)
SELECT Foo, Bar, @fizz, Buzz
FROM initial_table

插入语法是

insert into destination_table (destination_colum1, destination_colum2, ...)
select source_value1, source_value2, ...  from source_table

首先,您命名要写入的列,然后选择源

于 2012-05-18T16:10:33.900 回答