recordCheck = c.execute("SELECT * FROM Student, Behaviour WHERE Forename=:oldForename, Surname=:oldSurname, YearGroup=:oldYearGroup, FormNumber=:oldFormNumber, Date=:oldDate, BehaviourType=:oldBehaviourType", {"oldForename":oldForename, "oldSurname":oldSurname, "oldYearGroup":oldYearGroup, "oldFormNumber":oldFormNumber,"oldDate":oldDate,"oldBehaviourType":oldBehaviourType})
返回此错误:
OperationalError: near ",": syntax error
但是我看不出它有什么问题。有人可以帮忙吗?
答案 0 :(得分:2)
逗号在where
子句中无效。条件通常由AND
或OR
分隔。所以,这是无效的:
WHERE Forename=:oldForename, Surname=:oldSurname
其中一个是有效的:
WHERE Forename=:oldForename AND Surname=:oldSurname
WHERE Forename=:oldForename OR Surname=:oldSurname
答案 1 :(得分:0)
使用WHERE X=Y AND Y=Z
而不是WHERE X=Y, Y=Z
recordCheck = c.execute("SELECT * FROM Student, Behaviour WHERE Forename=:oldForename AND Surname=:oldSurname AND YearGroup=:oldYearGroup AND FormNumber=:oldFormNumber AND Date=:oldDate AND BehaviourType=:oldBehaviourType", {"oldForename":oldForename, "oldSurname":oldSurname, "oldYearGroup":oldYearGroup, "oldFormNumber":oldFormNumber,"oldDate":oldDate,"oldBehaviourType":oldBehaviourType})
答案 2 :(得分:0)
您在WHERE子句中使用逗号,您应该使用AND。