2

我不断遇到以下语句的错误:

cursor.execute("""INSERT into financial_statements (url) 
                  VALUES (%s) WHERE provider=%s AND date=%s""", (url, provider, date))

我得到的错误是:

_mysql_exceptions.ProgrammingError: (1064, "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 provider='ANGEL' AND date='2012-03-01'' at line 2")
4

2 回答 2

5

INSERT 语句不能有 WHERE 子句。

也许您打算执行更新?

UPDATE financial_statements
SET url = %s
WHERE provider=%s AND date=%s
于 2012-04-25T21:48:03.527 回答
4

WHERE在语句中使用是没有意义的INSERT——没有什么可以限制的。

如果要修改现有行,请使用UPDATE

UPDATE financial_statements SET url=%s WHERE provider=%s and DATE=%s
于 2012-04-25T21:48:11.903 回答