0

I try to execute the query but get an error. This is my query:

UPDATE 
    prepares_for_exam 
SET 
    prepares_for_exam.exam_id = product.id 
FROM 
    prepares_for_exam, 
    product 
WHERE 
    prepares_for_exam.id = product.prepares_for_exam_id

and I get the error:

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 prepares_for_exam, product WHERE prepares_for_exam.id = product.prepares_fo' at line 1

I did the Update Query 100-times with an FROM clause and never had problems... Whats my fault?!?

2 Answers 2

1

You are using the SQL-Server syntax. In MySQL it is a little bit different.

UPDATE 
    prepares_for_exam 
JOIN 
    product 
ON 
    prepares_for_exam.id = product.prepares_for_exam_id
SET 
    prepares_for_exam.exam_id = product.id 
Sign up to request clarification or add additional context in comments.

Comments

0
UPDATE 
prepares_for_exam 
SET 
prepares_for_exam.exam_id = (select product.id FROM 
prepares_for_exam JOIN product on prepares_for_exam.id = product.prepares_for_exam_id)

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.