1.SQL中left join,inner join 和right join的区别
left join左连接,查询结果包含满足条件的数据+左边表中的不满足条件的数据
inner join内连接,只查询满足条件的数据
right join 右连接,查询结果包含满足条件的数据+右边表中的不满足条件的数据
2.SQL中表的去重(删除表中重复的数据,只保留一条)
delete FROM
(
select row_number() over(partition by staffId order by STAFFID desc) rn ,* from whsUserCombine
) t where t.rn!=1
3.SQL中跨表数据同步问题
update p set p.AcceptanceDays=t.AcceptanceDays,p.repeatCycle=t.ReInspectionDays,p.protectDate=t.ExpiryDays,
p.buName=t.depCode
from partInfo p
LEFT JOIN ATPStockLimit_temp t on p.partId=t.partId where t.partId is not null
4.SQL中跨表数据新增问题
INSERT INTO partInfo(company,partId,safetyStock,stockUnit,prodInfo,acti)
select company,partId,safetyStock,stockUnit,prodInfo,acti from partInfo_temp t
where not exists(
select * from partInfo p where p.company = t.company and p.partId = t.partId
)
5.单例模式