我知道你可以这样做:
INSERT INTO AnotherTable (a, b, c, d)
SELECT a, b, c, d
FROM SomeTable
WHERE SomeColumn = 1
但是,如果SELECT a, b, c, d
您需要将这些列更新为a, b, c, "string"
说白了,我想要一个声明:
INSERT INTO AnotherTable (a, b, c, d)
SELECT a, b
FROM SomeTable
WHERE SomeColumn = 1
// And put "string" into d
更新
所以我运行了这个:
INSERT INTO AnotherTable (a, b, c, d)
SELECT a, b, c, 'string'
FROM SomeTable
WHERE SomeColumn = 1
它在“c”列中选择了 3 行具有不同条目的行,并通过插入完全相同的 3 行来更新“AnotherTable”。尽管它们应该是不同的值...