I want to retrieve last month data and my combo-box selected month date
this is my code and this query is not working. i think the problem is in INTERVEL command. Please help me to use INTERVAL 1 MONTH correctly.
$result = mysql_query("SELECT manufacturer,model, SUM(replace(payment_one,',','')) as payment_one FROM table1 WHERE
YEAR(payment_one_date) = '$YYYY'- INTERVAL 1 MONTH AND
MONTH(payment_one_date) = '$MM'-INTERVAL 1 MONTH AND
payment_one_bank='CB'");
SELECT
manufacturer,
model,
SUM(replace(payment_one,',','')) payment_one
FROM table1
WHERE (
payment_one_date < '$YYYY-$MM-01 00:00:00' /* <-- can be incorrect for your field type */
AND payment_one_date >= ('$YYYY-$MM-01 00:00:00' - INTERVAL 1 MONTH)
) AND payment_one_bank='CB'
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.