insert into table1 select * from table2 where userid not in(select userid from table1)
insert tb(userid) selct * from(userid = '要插入的userid') a where not exists( select * from tb where userid = a.userid)
insert into @table1 select table2.* from table2 left outer join table1 on table2.userid=table1.userid where table1.userid is null
insert into table1 select table2.* from table2 left outer join table1 on table2.userid=table1.userid where table1.userid is null
declare @table1 table(userid int,col1 int) insert into @table1 select 1,1 union select 2,2 union select 3,3 union select 4,4 select * from @table1 declare @table2 table(userid int,col1 int) insert into @table2 select 1,1 union select 2,2 union select 3,3 union select 4,4 union select 5,5 select * from @table2insert into @table1 select table2.* from @table2 table2 left outer join @table1 table1 on table2.userid=table1.userid where table1.userid is nullselect * from @table1;
insert into table1 select 要插入1,要插入2,... where ...中要插入userid的值 not in(select userid from table1)
where not exists(
select * from tb where userid = a.userid)
select table2.*
from table2 left outer join table1
on table2.userid=table1.userid where table1.userid is null
select table2.*
from table2 left outer join table1
on table2.userid=table1.userid where table1.userid is null
insert into @table1
select 1,1
union select 2,2
union select 3,3
union select 4,4
select * from @table1
declare @table2 table(userid int,col1 int)
insert into @table2
select 1,1
union select 2,2
union select 3,3
union select 4,4
union select 5,5
select * from @table2insert into @table1
select table2.*
from @table2 table2 left outer join @table1 table1
on table2.userid=table1.userid where table1.userid is nullselect * from @table1;
where not exists(
select * from tb_xiangcestory_black where userid = a.userid)消息 102,级别 15,状态 1,第 2 行
'=' 附近有语法错误。