How can I SQL insert a record for every id in another table?
This question already has an answer here:
The correct syntax does not use values :
insert into table1(col1, . . . )
select distinct id, 'blah', 'blah', 'blah'
from table2;
Notes:
insert , unless you really, really know what you are doing. The syntax looks like this:
insert into table1
select distinct id, 'blah', 'blah', 'blah' from table2
Use single quotes for string literals, like 'blah' . (Double quotes are for delimited identifiers, eg if an object has an reserved word as name "table" .)
上一篇: 将数据从一个表复制到另一个表并更改ID
