-2
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)

我怎样才能做到这一点?

4

2 回答 2

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
于 2013-10-23T06:39:44.627 回答
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
于 2013-10-23T06:40:28.057 回答