我想从mysql获取上个月的记录。我正在使用像this.it将返回上个月和去年的记录。
enter code here
select pt_product_name,
purhis_measurement,
purhis_quantity,
purhis_return_qty,
purhis_actual_qty,
purhis_per_qty_price,
purhis_ledgerid,
purhis_invoice_no,
purhis_purchase_dt,
purhis_invoice_dt,
purhis_type_of_purchase,
purhis_mode_of_purchase
from purchasehis_tb as pur,product_tb as pt
where pt.pt_bt_branchid='BRA102451717858'
and pt.pt_productid=pur.purhis_pt_productid
and pur.purhis_updated_dt>subdate(curdate(),interval 1 month)
答案 0 :(得分:0)
尝试thiz:
select pt_product_name,
purhis_measurement,
purhis_quantity,
purhis_return_qty,
purhis_actual_qty,
purhis_per_qty_price,
purhis_ledgerid,
purhis_invoice_no,
purhis_purchase_dt,
purhis_invoice_dt,
purhis_type_of_purchase,
purhis_mode_of_purchase
from purchasehis_tb as pur,product_tb as pt
where pt.pt_bt_branchid='BRA102451717858'
and pt.pt_productid=pur.purhis_pt_productid
and pur.purhis_updated_dt BETWEEN SUBDATE(CURDATE(), INTERVAL 1 MONTH) AND NOW()