MariaDB 的 HeidiSQl 错误语法错误

HeidiSQl error for MariaDB for wrong syntax

我收到这个错误:

You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near

这是我的 SQL:

UPDATE product
SET cost_price = db2.supplier.Cost_price
FROM product, db2.supplier WHERE product.SKU = db2.supplier.SKU;

我该如何解决?

尝试使用此连接语法:

UPDATE product
INNER JOIN  db2.supplier ON product.SKU = db2.supplier.SKU
SET product.cost_price = db2.supplier.Cost_price

MariaDB 中 UPDATE 没有 FROM 子句。只需使用 JOIN 代替:

UPDATE product p JOIN
       db2.supplier s
       ON p.SKU = s.SKU
    SET p.cost_price = s.Cost_price;

注意 table 别名和显式 JOIN 语法的使用!