gpt4 book ai didi

mysql - 保修期已过?

转载 作者:行者123 更新时间:2023-11-29 13:37:28 25 4
gpt4 key购买 nike

我有两个值,一个 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

但似乎不起作用

最佳答案

SELECT
*
FROM
items
WHERE
NOW() > (invoice_date + INTERVAL warranty_period YEAR)

关于mysql - 保修期已过?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18558053/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com