base.name, base.year
, a.成绩 as [a表成绩]
, b.成绩 as [b表成绩]
, case
when a.成绩 is null then 'a表中不存在'
when b.成绩 is null then 'b表中不存在'
when a.成绩=b.成绩 then '成功'
else '差异' end as 比较结果
from (
select name, year from tb_a
union
select name, year from tb_b
) as base
left join tb_a as a on a.name=base.name and a.year=base.year
left join tb_b as b on b.name=base.name and b.year=base.year
select A.* from A, B
where A.A1=B.B1 -- 相同主键,做表连接.
and A.A2 <>B.B2 -- 条件:A2不等于B2.
and A.A3 <>B.B3 -- 条件:A3不等于B3.
知识延展:
sql 语句是对数据库进行 *** 作的一种语言。
结构化查询语言(Structured Query Language)简称SQL,结构化查询语言是一种数据库查询和程序设计语言,用于存取数据以及查询、更新和管理关系数据库系统。
insertinto
tablea
select
*
from
tablea
where
not
exists
(selelct
'1'
from
tableb
where
tablea.serverid
=
serverid
and
tablea.driverid
=
driverid
and
tablea.driversize
=
driversize)
update
tablea
set
tablea.driversize
=
tablea.driversize
from
tablea
,tableb
where
tablea.serverid
=
serverid
and
tablea.driverid
=
driverid
如果你以tableb为准的话,你最好在tableb上加个触发器
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)