2013-10-23 115 views
-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; 

我想這個條件添加到上述查詢添加在MySQL查詢一個條件

edited_date < DATE_SUB(now(), interval 48 hour) 

我怎樣才能做到這一點?

+1

應被視爲/? –

+0

你的意思是edited_date shuold be equals「edited_date」? –

+0

edited_date user100613

回答

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