34,590
社区成员
发帖
与我相关
我的任务
分享
insert into t_tjly(newsid,news_tjto) select * from (
select '240' as newsid,'4' as news_tjto
union all
select '246' as newsid,'4' as news_tjto
union all
select '248' as newsid,'4' as news_tjto
) t where not exists( select 1 from t_tjly where newsid=t.newsid and news_tjto=t.news_tjto)
insert into t_tjly(newsid,news_tjto)
select * from (select '240' as newsid,'4' as news_tjto) t where not exists(
select 1 from t_tjly where newsid=t.newsid and news_tjto=t.news_tjto)
create table tb(id int,name varchar(50))
insert into tb select 1,'a'
insert into tb select 2,'b'
insert into tb select 3,'c'
insert into tb(id,name)
select * from (select 1 as id ,'a' as name) t where not exists(
select 1 from tb where id=1 and name='a')
select * from tb
ID newsid a b
1 240 4 1
2 240 5 1
3 240 6 2
4 241 3 1
5 241 4 1
insert into tb(newsid,a,b)
select newsid,a,b from ta a
where not exists(select 1 from tb b where a.newsid=b.newsid and a.a=b.a)
insert 插入表
select * from newsid where checksum(newsid,a)not in(select checksum(newsid,a) from 插入表)
insert into [你要插入的表名](id,newsid,a,b)
select id,newsid,a,b from [数据来源表] t where id not in(
select id from [你要插入的表名]
)