select B.*
from test.dbo.m2 B
where NOT EXISTs(select 1 from test.dbo.m1 A where A.姓名=B.姓名 and A.年齡 = B.年齡 and A.學歷=B.學歷)
select 編碼, 通用名, 質量層次,count(*) from test.dbo.外表 A
group by 編碼, 通用名, 質量層次
having count(*)>1
update a set a.[企業ID]=b.EnterpriseID from xzwsy a,Enterprise_info b where a.[企業名]
=b.EnterpriseName
匹配多行列平均賦值
update 表a set a3=(select avg(b3) from 表b where 表b.b1=表a.a1)
插入a表b表中不存在於A表的數據
insert into a
select xx from b where not exists (select xx from a where b.xx=a.xx)