-4

我创建了这段代码,但它似乎不起作用。在 where 子句 paymentnotification.subpayment 和 collections.status 中是否正确

    $sql = "SELECT collections.categoryid,collections.handler,collections.status,paymentnotification.categoryid,paymentnotification.amount,paymentnotification.payee,paymentnotification.paymentdate 
FROM collections
INNER JOIN paymentnotification
ON paymentnotification.month=collections.month AND paymentnotification.categoryid=collections.categoryid
 WHERE paymentnotification.subpayment=? AND  collections.status=? AND collections.year=? BETWEEN ? AND ?";
$p = $conn->prepare($sql);
$p->execute(array($payment,$status,$year,$monthc,$monthc2));
4

1 回答 1

3

一个问题是:

AND collections.year=? BETWEEN ? AND ?

显然应该是这样的:

AND collections.year=? AND collections.month BETWEEN ? AND ?

(顺便说一句,我建议使用较短的行,并放置好换行符。当您必须水平滚动才能阅读每一行时,就很难理解了。)

于 2013-06-01T18:29:37.027 回答