我不知道为什么继续返回:

#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'FROM vendas LEFT JOIN clientes c ON c.id = vendas.idCliente AND c.idRespons' at line 2

MySQL查询:

UPDATE vendas
FROM vendas
LEFT JOIN clientes c ON c.id = vendas.idCliente AND c.idResponsavel IS NOT NULL
LEFT JOIN funcionarios f ON f.id = c.idResponsavel
SET vendas.idVendedorResponsavel = f.id
WHERE vendas.idVendedorAtendente is NULL

最佳答案

尝试这个

UPDATE vendas v

LEFT JOIN clientes c
ON c.id = v.idCliente
AND c.idResponsavel IS NOT NULL

LEFT JOIN funcionarios f
ON f.id = c.idResponsavel

SET v.idVendedorResponsavel = f.id
WHERE v.idVendedorAtendente is NULL

关于mysql - 带连接的SQL Update无法正常工作我在这里缺少什么?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/26420922/

10-13 02:55