我有两个值,一个 InvoiceDate(格式:YYYY-MM-DD)和一个 WarrantyPeriod(格式:nn)(保修年数)
一个简单的查询来选择保修已过期的项目?
我试过这个:
SELECT
*
FROM
(
SELECT
UNIX_TIMESTAMP(DATE_FORMAT(item_invoice_date, '%Y-%m-%d %H:%i:%s')) AS ux_id,
(item_warranty_period * 365 * 86400) AS ux_wp
FROM
items
WHERE
items.item_warranty_period > 0
AND
items.item_invoice_date != '0000-00-00'
) wd
,items
WHERE
items.item_warranty_period > 0
AND
items.item_invoice_date != '0000-00-00'
AND
wd.ux_id - wd.ux_wp < UNIX_TIMESTAMP(NOW())
GROUP BY
items.item_id
但似乎没有工作