0
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

但我看不出它有什么问题。任何人都可以帮忙吗?

4

3 回答 3

2

where逗号在子句中无效。条件通常由AND或分隔OR。所以,这是无效的:

WHERE Forename=:oldForename, Surname=:oldSurname

其中之一将是有效的:

WHERE Forename=:oldForename AND Surname=:oldSurname

WHERE Forename=:oldForename OR Surname=:oldSurname
于 2014-03-01T21:12:15.553 回答
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})
于 2014-03-01T21:12:06.423 回答
0

您在 WHERE 子句中使用逗号,并且应该使用 AND。

于 2014-03-01T21:12:53.900 回答