I'm using the Python MySQL connector to add data to a table by updating the row. A user enters a serial number, and then the row with the serial number is added. I keep getting a SQL syntax error and I can't figure out what it is.
query = ("UPDATE `items` SET salesInfo = %s, shippingDate = %s, warrantyExpiration = %s, item = %s, WHERE serialNum = %s")
cursor.execute(query, (info, shipDate, warranty, name, sn, ))
conn.commit()
Error:
mysql.connector.errors.ProgrammingError: 1064 (42000): 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 'WHERE serialNum = '1B0000021A974726'' at line 1
"1B0000021A974726" is a serial number inputted by the user and it is already present in the table.
asked Feb 14, 2019 at 22:20
ajjohnson190
5132 gold badges7 silver badges21 bronze badges
1 Answer 1
No , before the WHERE statement
answered Feb 14, 2019 at 22:21
danblack
14.9k2 gold badges27 silver badges49 bronze badges
Sign up to request clarification or add additional context in comments.
Comments
default
,before theWHERE