このコードを作成しましたが、機能していないようです。where句の支払い通知.サブ支払いとコレクション.ステータスに正しいですか
$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));