0

I am getting a strange MYSQL error when trying to write a row to a database - every solution I have found concerning the topic hasn't been helpful. The query being passed is this:

"INSERT INTO StaffData (StaffID,Sort,Name,Department,Occupation,Roles,Phone,Email,Notes,Password) VALUES (@StaffID,@Sort,@Name,@Department,@Occupation,@Roles,@Phone,@Email,@Notes,@Password) ON DUPLICATE KEY UPDATE"

And the return value is:

"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 '' at line 1"

The strange part to me is that it doesn't say where the error in syntax is, and I'm not sure why. Every other instance of this error I have found at least provides that.

Any help would be appreciated - thanks in advance!

0

1 Answer 1

5

Your error is in the syntax for "ON DUPLICATE KEY UPDATE".

You can't end a query there, MYSQL wants you to specify exactly which fields should be updated and how. The docs for how to do that can be found here.

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

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.