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)
我怎样才能做到这一点?
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)
我怎样才能做到这一点?
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
如果要连接两个表,请使用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