我有两个名为price_old和price_new的表,结构相同。
以下代码:
cursor = connection.cursor()
cursor.execute("""
UPDATE price_old a
JOIN price_new b
ON a."name" = b."name" and a."description" = b."description"
SET a."price = b."price"
""")
如果描述和名称匹配,此查询将使用price_new表的价格更新price_old表的价格。
但是我遇到了以下错误消息:
File "C:\Python34\lib\site-packages\mysql\connector\cursor.py", line 507, in execute
self._handle_result(self._connection.cmd_query(stmt))
File "C:\Python34\lib\site-packages\mysql\connector\connection.py", line 722, in cmd_query
result = self._handle_result(self._send_cmd(ServerCmd.QUERY, query))
File "C:\Python34\lib\site-packages\mysql\connector\connection.py", line 640, in _handle_result
raise errors.get_exception(packet)
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 '"name" = b."name" and a."description" = b."description"
SET a."price = b."pric' at line 3
你能帮助我吗?我是否会错过收尾报价?感谢:)