一句话解决更新和插入的问题
if exists(select 1 from Pat_ResultScores where SID=:SID) update Pat_ResultScores set Scores=:Scores,UserY=:UserY,UserP=:UserP where SID=:SID else insert into Pat_ResultScores(SID,Scores,UserY,UserP) values(:SID,:Scores,:UserY,:UserP)
本文介绍了一种使用SQL语句高效地实现数据更新或插入的方法。通过一条语句即可完成对已有记录的更新或新记录的插入操作,适用于需要快速同步数据的场景。
一句话解决更新和插入的问题
if exists(select 1 from Pat_ResultScores where SID=:SID) update Pat_ResultScores set Scores=:Scores,UserY=:UserY,UserP=:UserP where SID=:SID else insert into Pat_ResultScores(SID,Scores,UserY,UserP) values(:SID,:Scores,:UserY,:UserP)
1830

被折叠的 条评论
为什么被折叠?