所以我有这个查询
query = "SET @rownumber = 0; UPDATE students SET roll_no = (@rownumber := @rownumber+1) WHERE standard='{}' AND division='{}' ORDER BY fname, lname".format(standard, division)
当我尝试使用 运行此查询cursor.execute(query)
时,我收到以下错误
pymysql.err.ProgrammingError: (1064, "You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near 'UPDATE students SET roll_no = (@rownumber := @rownumber+1) WHERE standard='4' AN' at line 1")
但是当我在 MYSQL 工作台上运行它时,同样的查询可以正常工作吗?为什么它不工作,我怎样才能让它工作?