1
UPDATE dondathang
SET noigiaohang=diachi
FROM khachhang
WHERE dondathang.makhachhang=khachhang.makhachhang AND noigiaohang IS NULL;

I have a SQL code like above, but this is the error.

syntax error 'from' identifier is not valid input at this position.

What's wrong with my code?

3 Answers 3

1

FROM clause is irrelevant in UPDATE sintax. Please take a look at the documentation.

Sign up to request clarification or add additional context in comments.

Comments

0

FROM Clause is not a part of UPDATE syntax, you can change the UPDATE as below

UPDATE dondathang
SET noigiaohang=diachi
JOIN khachhang ON dondathang.makhachhang=khachhang.makhachhang
WHERE noigiaohang IS NULL;

Comments

0

The correct syntax in MySQL is:

UPDATE dondathang d JOIN
       khachhang k
       ON d.makhachhang = k.makhachhang
    SET d.noigiaohang = k.diachi
WHERE d.noigiaohang IS NULL;

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.