2012-10-03 73 views
0

我正在嘗試此查詢,但它在子查詢中輸出語法錯誤。當子查詢匹配時更新表

什麼問題和如何解決?感謝

UPDATE CompradorCategorias_new as A 
    SET A.idParent=(
     SELECT idcategoria 
     FROM categoriasi18n_new 
     WHERE 
     (
      SELECT SUBSTRING_INDEX(NomeComPath, '>', 2) 
      FROM CompradorCategorias_new 
      = 
      SELECT translationWithPath 
      FROM categoriasi18n_new 
     ) 
    ) 
+0

具體是什麼語法錯誤? –

回答

1

一切看起來好您的查詢直到WHERE條款 - 在這一點上,它的各種錯誤。實際上,你可以丟棄塊,並使用常用WHERE條款比較(而不是第二子查詢):

UPDATE 
    CompradorCategorias_new AS A 
SET 
    A.idParent = (
     SELECT 
      idcategoria 
     FROM 
      categoriasi18n_new AS B 
     WHERE 
      B.translationWithPath = SUBSTRING_INDEX(A.NomeComPath, '>', 2) 
    )