我正在使用 Python MySQL 连接器通过更新行来将数据添加到表中。用户输入序列号,然后添加包含序列号的行。我不断收到 SQL 语法错误,但无法弄清楚它是什么。
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()
错误:
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”是用户输入的序列号,它已经存在于表中。
最佳答案
WHERE
语句之前没有 ,
关于python - mysql.connector.errors.ProgrammingError : Error in SQL Syntax,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54699959/