0

我在准备好的语句中使用多个 WHERE 子句尝试访问 mysql 数据时出错。这是生成sql异常的代码(参数索引超出范围(2>参数数量,即1);

"SELECT Arrived_time, Closed_time FROM ? 
WHERE (\"Year  = ?\n) AND (\"Month = ?\n) AND (\"Day = ?)" 

我输入了三个参数。有没有更好的办法?

4

2 回答 2

1

如前所述,您需要指定表名并使用正确的引用:

"SELECT `Arrived_time`, `Closed_time` FROM TABLENAME
WHERE (`Year`  = ?) AND (`Month` = ?) AND (`Day` = ?)" 
于 2013-01-13T23:33:04.030 回答
0

"Year"命名列、"Month"和时缺少右引号"Day"

"SELECT Arrived_time, Closed_time FROM ? 
WHERE (\"Year\"  = ?\n) AND (\"Month\" = ?\n) AND (\"Day\" = ?)" 

在您的版本中,数据库将寻找一个名为的列"Year = ?\n) AND ("

于 2013-01-13T23:10:38.560 回答