0

I am trying to insert data in a specific row using MYSQL in PYTHON.

I've tried the following code :

sql = "INSERT INTO board (pages) VALUES (%s) WHERE (ASIN) = '" + asinList[x] + "'"
val = (a)
myCurser.execute(sql, val)

However, I got this error :

"

mysql.connector.errors.ProgrammingError: 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '%s) WHERE (ASIN) = 'B07KWSRMK1'' "

how to solve it?

1 Answer 1

1

INSERT does not support WHERE clause with VALUES.

If you really want add a new rows then you should use INSERT.

 sql = "INSERT INTO board (pages) VALUES (%s) '"

You may be looking to update an existing row. In this you should use UPDATE:

sql = "UPDATE  board 
       SET pages = %s
       WHERE ASIN  = %s"
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.