0

I have the current code,

UPDATE i
SET LeadInventor = 
    CASE 
        WHEN gs.FirstInventorName IS NULL THEN 'No' 
        ELSE 'Yes' 
    END
FROM patentdb.Inventor i
    LEFT JOIN patentdb.generalsource gs
    ON i.InventorFirst + ' ' + i.InventorLast = gs.FirstInventorName

and I dont understand why it throws the following error:

Error Code: 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 patentdb.Inventor i     LEFT JOIN patentdb.generalsource gs     ON i.Invent' at line 7

The FROM statement is what MYSQL is underlining

2 Answers 2

1

This is because the FROM clause isn't valid in a MySQL UPDATE statement:

http://dev.mysql.com/doc/refman/5.6/en/update.html

You may have better luck with this:

UPDATE Inventor i, generalsource gs
SET i.LeadInventor = CASE
  WHEN gs.FirstInventorName IS NULL THEN 'No'
  ELSE 'Yes'
END
WHERE i.InventorFirst + ' ' + i.InventorLast = gs.FirstInventorName
Sign up to request clarification or add additional context in comments.

Comments

0

The syntax is incorrect. Have a look at this query:

UPDATE patentdb.Inventor i
  LEFT JOIN patentdb.generalsource gs
  ON CONCAT(i.InventorFirst, ' ', i.InventorLast) = gs.FirstInventorName
SET LeadInventor = 
  CASE WHEN gs.FirstInventorName IS NULL THEN 'No' ELSE 'Yes' END

In addition, I want to say that in MySQL it is better to use CONCAT function to make new string.

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.