1

In this error it indicates that the

"FROM is not a valid input at this position".

Here is the code which is an insert statement with JOIN clause

UPDATE phpcollab.projects

SET ph.APPROVED='2',
    pd.currentBudget = pd.currentbudget - ph.totalvalue

FROM phpcollab.projects pp JOIN phpcollab.photo ph
                             ON pp.projectID = ph.id
WHERE ID='1';

1 Answer 1

6

MySQL's update-join syntax doesn't use a from clause:

UPDATE phpcollab.projects pp
JOIN   phpcollab.photo ph ON pp.id = ph.projectID
SET    ph.APPROVED = '2',
       pp.currentBudget = pp.currentbudget - ph.totalvalue
WHERE  ph.id = '1';
Sign up to request clarification or add additional context in comments.

2 Comments

Is there anyway I could call the data from the other table? Because I want to subtract a data from the photos table to the projects table
@MarcoM. Of course - you can use table aliases and relate to data in the other table(s) like my example shows.

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.