关于多表Update和Delete的应用


Declare @TempFrontEndJobMagt table (JobID int, ShareAccountID int, ShareEntityID int)  
INSERT INTO @TempFrontEndJobMagt (
 JobID,
 ShareAccountID,
 ShareEntityID
) VALUES (
 /* JobID - int */ 65,
 /* ShareAccountID - int */ 12100307,
 /* ShareEntityID - int */ 1 )
 
SELECT * FROM @TempFrontEndJobMagt 

UPDATE Job_Status SET IsCrossPostJob = 0
FROM dbo.Job_Status S, @TempFrontEndJobMagt T
WHERE AccountID=12100308 AND EntityID=1 AND S.JobID = T.JobID


DELETE Job_Status
FROM Job_Status S
INNER JOIN @TempFrontEndJobMagt T ON S.JobID = T.JobID
Where AccountID=12100308 AND EntityID=1

你可能感兴趣的:(update)