SELECT ord_no,name, mobile, address, rate, mrp, create_date, edited_date,status
FROM orders o, customer c
where o.cust_id = c.id and status = 'CHECKED' order by 1;
我想将此条件添加到上述查询
edited_date < DATE_SUB(now(), interval 48 hour)
我该怎么做?
答案 0 :(得分:0)
SELECT ord_no,name, mobile, address, rate, mrp, create_date, edited_date, status
FROM orders o, customer c
where o.cust_id = c.id
and status = 'CHECKED'
and edited_date < now() - interval 48 hour
答案 1 :(得分:0)
如果要加入两个表,请使用JOIN
运算符。
为什么不添加所需的WHERE
子句?必须在ORDER BY
:
SELECT ord_no, name, mobile, address, rate, mrp, create_date, edited_date, status
FROM orders o
INNER JOIN customer c
ON o.cust_id = c.id
WHERE status = 'CHECKED'
AND edited_date < DATE_SUB(now(),interval 48 hour)
ORDER BY 1