gpt4 book ai didi

mysql - 内部错误 : (1242, 'Subquery returns more than 1 row' )

转载 作者:行者123 更新时间:2023-11-29 11:05:44 24 4
gpt4 key购买 nike

执行此代码时出现内部错误

conn = pymysql.connect(user = 'root', password = '', unix_socket = "/tmp/mysql.sock", database = 'abc' )
cursor = conn.cursor()
query2 = """INSERT INTO paragraphVector (termId, termFreq, kgram) VALUES ((SELECT termId FROM term WHERE term = %s AND kgram = %s), %s, %s)"""

insertDocVec = [(str(term), str(kgram), tf[kgram][term], str(kgram)) for kgram in tf for term in tf[kgram]]
cursor.executemany(query2, insertDocVec)
conn.commit()

最佳答案

更改此:

INSERT INTO paragraphVector (termId, termFreq, kgram) VALUES ((SELECT termId FROM term WHERE term = %s AND kgram = %s), %s, %s)

对此:

INSERT INTO paragraphVector (termId, termFreq, kgram) SELECT termId, %s, %s FROM term WHERE term = %s AND kgram = %s

并将最后两个参数向左移动

关于mysql - 内部错误 : (1242, 'Subquery returns more than 1 row' ),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41445290/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com