2015-09-18 40 views
-1

這是我的正常工作選擇查詢:更新與子查詢不工作的MySQL

SELECT PRICE.PRICEDATETO AS PDF 
    ,ATTR.PRICEDATEFROM AS ADF 
    ,ATTR.PRICEDATETO AS ADT 
    FROM RT_DATA_CORE DCORE 
     INNER JOIN RT_DATA_PRICE PRICE ON DCORE.ID=PRICE.ID 
     INNER JOIN RT_PRODUCT_CORE PCORE ON PCORE.ID=PRICE.PRODUCTID 
     INNER JOIN RT_DATA_PRICEATTRIBUTES ATTR ON   
       CONCAT(ATTR.PRODUCTID,'_V')=PCORE.SKU 
      AND PRICE.ID='PRICE-26095657' 
      AND ATTR.PRICEDATETO>NOW() 
    ORDER BY ATTR.PRICEDATETO ASC LIMIT 1; 

我需要將其更新到ADF = PDF

我想這裏面給我一個錯誤:

mysql> UPDATE RT_DATA_PRICE PRICE INNER JOIN (SELECT PA.PRICEDATETO AS DATER,PCORE.ID AS PID FROM RT_DATA_PRICEATTRIBUTES PA,RT_PRODUCT_CORE PCORE WHERE PA.PRICEDATETO > NOW() AND PCORE.SKU = CONCAT(PA.PRODUCTID,'_V') ORDER BY PA.PRICEDATETO ASC LIMIT 1)AOP ON AOP.PID=PRICE.PRODUCTID AND PRICE.ID='PRICE-26095657' SET AOP.DATER=PRICE.PRICEDATETO; ERROR 1288 (HY000): The target table AOP of the UPDATE is not updatable

+0

好的,你能告訴我們你的更新不是錯誤嗎? – Marusyk

回答

0

RT_DATA_CORE不被使用所以我刪除它,試試這個

UPDATE RT_DATA_PRICE PRICE, RT_PRODUCT_CORE PCORE, RT_DATA_PRICEATTRIBUTES ATTR 
SET ATTR.PRICEDATEFROM = PRICE.PRICEDATETO 
WHERE 
    PCORE.ID=PRICE.PRODUCTID 
    CONCAT(ATTR.PRODUCTID,'_V')=PCORE.SKU 
    AND PRICE.ID='PRICE-26095657' 
    AND ATTR.PRICEDATETO>NOW();