我想更新从 PI 表中选择的三列,即 LCID、LCNo、AmendmentStatus,所以我编写了以下成功执行的更新查询:
UPDATE #TempTableOne
SET
LCID=(SELECT ISNULL(ExportLCID,0) FROM ExportLC WHERE ExportLCID= (SELECT LCID FROM [PI] WHERE PIID=(SELECT PIID FROM Job WHERE JobID=TT.OrderID))),
LCNo=(SELECT ISNULL(ExportLCNo,'') FROM ExportLC WHERE ExportLCID= (SELECT LCID FROM [PI] WHERE PIID=(SELECT PIID FROM Job WHERE JobID=TT.OrderID))),
AmendmentStatus=(SELECT AmendmentStatus FROM ExportLC WHERE ExportLCID= (SELECT LCID FROM [PI] WHERE PIID=(SELECT PIID FROM Job WHERE JobID=TT.OrderID))),
FROM #TempTableOne AS TT
WHERE TT.OrderType=3
但是是否有可能更新查询执行单个查询,例如:
Update #TempTableOne
SET SELECT LCID = ISNULL(ExportLCID,0) ,
LCNo=ISNULL(ExportLCNo,''),
AmendmentStatus=AmendmentStatus
FROM ExportLC
WHERE ExportLCID = (SELECT LCID
FROM [PI]
WHERE PIID=(SELECT PIID
FROM Job
WHERE JobID=TT.OrderID
)
)
)
因为我想加快我的查询