我正在使用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”是用户输入的序列号,已经存在于表中。
答案 0 :(得分:1)
No ,
before the WHERE
statement