我在准备好的语句中使用多个 WHERE 子句尝试访问 mysql 数据时出错。这是生成sql异常的代码(参数索引超出范围(2>参数数量,即1);
"SELECT Arrived_time, Closed_time FROM ?
WHERE (\"Year = ?\n) AND (\"Month = ?\n) AND (\"Day = ?)"
我输入了三个参数。有没有更好的办法?
如前所述,您需要指定表名并使用正确的引用:
"SELECT `Arrived_time`, `Closed_time` FROM TABLENAME
WHERE (`Year` = ?) AND (`Month` = ?) AND (`Day` = ?)"
"Year"
命名列、"Month"
和时缺少右引号"Day"
:
"SELECT Arrived_time, Closed_time FROM ?
WHERE (\"Year\" = ?\n) AND (\"Month\" = ?\n) AND (\"Day\" = ?)"
在您的版本中,数据库将寻找一个名为的列"Year = ?\n) AND ("