2014-10-09 65 views
-4

我有這個UPDATE查詢:內連接查詢的更新語句給錯誤

UPDATE secugconductorinfo 
     INNER JOIN tblsecugconductor 
       ON secugconductorinfo.CONDUCTORGUID = tblsecugconductor.globalid 
SET secugconductorinfo.conductorcount = '0' 
WHERE Upper(tblsecugconductor.FILE_NAME) LIKE '%Q1222_S%' 
     AND secugconductorinfo.conductorsize = 'Unknown' 
     AND secugconductorinfo.insulation = 'Unknown' 
     AND secugconductorinfo.material = 'Unknown' 
     AND secugconductorinfo.conductorcount = '1' 

我想更新conductorcount=0基於與tblsecugconductor聯接secugconductorinfo的所有行。
但我發現了:

Error report: SQL Error: ORA-00971: missing SET keyword 00971. 00000 - "missing SET keyword"

我應該如何改變我的查詢來執行此更新?

+5

有什麼錯誤?你使用的是什麼RDBMS? – Mureinik 2014-10-09 12:54:38

+1

什麼是確切的錯誤? – 2014-10-09 12:56:09

+0

我們需要更多信息來幫助您。請告訴我們你試圖用這個查詢來完成什麼,以及發生了什麼。如果您收到錯誤訊息,請顯示它。您可以使用上方的「修改」鏈接編輯您的帖子。祝你好運! – 2014-10-09 13:10:20

回答

0
UPDATE secugconductorinfo 
SET secugconductorinfo.conductorcount = '0' 
WHERE secugconductorinfo.conductorsize = 'Unknown' 
     AND secugconductorinfo.insulation = 'Unknown' 
     AND secugconductorinfo.material = 'Unknown' 
     AND secugconductorinfo.conductorcount = '1' 
AND exists (select 1 
      from tblsecugconductor 
      where secugconductorinfo.CONDUCTORGUID = tblsecugconductor.globalid 
       and Upper(tblsecugconductor.FILE_NAME) LIKE '%Q1222_S%') 

您應該使用exists語句來進行連接。我更正了上面的代碼。

0

試試這個:

UPDATE secugconductorinfo 
SET conductorcount ='0' 
from secugconductorinfo aa 
INNER JOIN tblsecugconductor bb 
     ON aa.CONDUCTORGUID = 
       bb.globalid 

WHERE Upper(bb.FILE_NAME) 
       LIKE '%Q1222_S%' 
    AND aa.conductorsize = 'Unknown' 
    AND aa.insulation = 'Unknown' 
    AND aa.material = 'Unknown' 
    AND aa.conductorcount = '1'