27,579
社区成员
发帖
与我相关
我的任务
分享
INSERT INTO a
SELECT
account,
1,
0,
Session1ID,
getdate()
FROM
b
WHERE
account not in (
SELECT
b.account
FROM
b,a
WHERE
Session1ID is not null
and b.account=a.account
GROUP BY
b.account
)
if (b.Session1ID is not null)
insert into
a
select
*
from
b where
Session1ID is not null
and
not exists (select 1 from a where Session1=True and b.Session1ID=a.Account)
if(b.Session2ID is not null)
insert
a
select
*
from
b
where
Session2ID is not null
and
not exists (select 1 from a where Session2=True and b.Session2=a.Account)
--2.
insert a
select * from b where Session2ID is not null
and not exists (select 1 from a where Session2=True and b.Session2=a.Account)
--1.
insert a
select * from b where Session1ID is not null
and not exists (select 1 from a where Session1=True and b.Session1ID=a.Account)
insert into table1 select * from table2 where 条件
select * into table2 from table1 where 1<>1 --只建一个相同的表不复制数据
select * into table2 from table1 where 1<>2 --创建表并复制数据...
insert into b select * from a where a.account not in(select b.account from b)