试图更新并遇到错误

时间:2013-10-03 06:37:07

标签: mysql

好吧,我一整天都在尝试这样做。我知道这个问题之前已被提出并得到解答,但我无法解决如何使这项工作的问题。

UPDATE 'domain_main.registrarMultiID' =
(
    SELECT r.MultiID#, m.RecId, d.domainId
    FROM domain_main d, Master m, registrar_accounts_multi r
    WHERE d.domainId = m.RecId
    AND r.account = m.Account_CustomerNumber
    AND r.password = m.Password
    AND r.logonName = m.Logon_Username
)

我在这里缺少什么?我理解我不应该在select中引用domain_main,但我不知道如何以另一种方式解决这个问题。

1 个答案:

答案 0 :(得分:1)

你的语法错误

  UPDATE 'domain_main.registrarMultiID' =
    (
        SELECT r.MultiID#, m.RecId, d.domainId
        FROM domain_main d, Master m, registrar_accounts_multi r
        WHERE d.domainId = m.RecId
        AND r.account = m.Account_CustomerNumber
        AND r.password = m.Password
        AND r.logonName = m.Logon_Username
    )

如下所示更正语法。我假设您要将registrarMultiID表的domain_main列的值设置为属于MultiID#表的registrar_accounts_multi列值。

UPDATE 'domain_main' As d
INNER JOIN Master as m
   ON d.domainId = m.RecId
INNER JOIN registrar_accounts_multi as r
   ON r.account = m.Account_CustomerNumber
      AND r.password = m.Password
      AND r.logonName = m.Logon_Username
SET d.registrarMultiID = r.MultiID#