sql两个表比较
❶ sql如何对比两张表的数据
insert
into
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上加个触发器
❷ sql查询、对比两个表
select id from works minus select w_id from data_1 --这个运算起来较快,works有的data_1没有
select id from works intersect select w_id from data_1 --两个数据库交叉的部分
❸ 怎么用sql语句把两个表,两个字段进行比较
select y.F,x.B from 表1 x left join 表2 y on x.A=y.E order by x.B
❹ 在SQL Server中如何比较两个表的各组数据
假设两个表都有唯一键UserID
可以这么写(使用全连接【full outer join】:完整外部联接返回左表和右表中的所有行。当某行在另一个表中没有匹配行时,则另一个表的选择列表列包含空值。如果表之间有匹配行,则整个结果集行包含基表的数据值。)
select *from RCSA_UserInfoDEL a full outer join RCSA_UserInfo b on a.UserID=b.UserIDwhere a.UserID is null or b.UserID is null