我有两个表格,它们都有一个名为
我尝试了以下代码,但它提示
id
的相同列,但是table1
中的id
比table2
多。现在我想要找到那些在table1
中存在但在table2
中不存在的id
,并将它们插入
到table2
中,并将它们的计数值设置为0。我尝试了以下代码,但它提示
syntax error, unexpected IF
。if not exists(select * from table1 where table1.id = table2.id)
begin
insert into table2 (id, count) values (table1.id, 0)
end