我在pymysql上运行它,它似乎有一个语法问题,虽然在工作台上,如果我用随机值repace%s它工作正常。我做错了什么?还有完整的错误行是这个ProgrammingError(1064, “您的SQL语法有错误;请查看与您的MySQL服务器版本对应的手册,以便在'3226''附近使用正确的语法。)\ n GROUP BY a2.actor_id ='''3226'',a1.actor_id \ n有计数(第9行的DISTINC')
sql_query='''SELECT a1.actor_id as i8opoios1 FROM actor as a1
INNER JOIN actor as a2 on a1.actor_id != a2.actor_id
INNER JOIN role as r1 on a1.actor_id = r1.actor_id
INNER JOIN movie as m1 on m1.movie_id = r1.movie_id
INNER JOIN movie_has_genre as mg1 on mg1.movie_id = m1.movie_id
INNER JOIN role as r2 on a2.actor_id = r2.actor_id
INNER JOIN movie as m2 on m2.movie_id = r2.movie_id
INNER JOIN movie_has_genre as mg2 on mg2.movie_id = m2.movie_id
WHERE (a2.actor_id='%s')
GROUP BY a2.actor_id='%s',a1.actor_id
HAVING count(DISTINCT mg1.genre_id) + count(DISTINCT mg2.genre_id)>=7
AND SUM(mg1.genre_id = mg2.genre_id) = 0'''
cur.execute(sql_query,(actorId,actorId))
results=cur.fetchall()