我有一个名为orders
的表,其中包含名为date_received
和status
的列。 date_received
列包含日期,status
列的整数为0-3;
是否可以删除行,其中我的唯一标准是它已经过了2天且状态列仍为0。
有点像这样:
DELETE * FROM orders WHERE (current_date - date_received = 2 days) AND status = 0;
答案 0 :(得分:3)
是。正确的陈述是:
DELETE o
FROM orders o
WHERE date_received <= date_sub(current_date, interval 2 day) and
status = 0;