2010-05-09 105 views
4

With Coldfuson & MySQL - 如何更新查詢以檢查是否有過去24小時內發生時間戳的新條目?MySQL,Coldfusion,選擇在過去24小時內加時間戳的記錄

查詢:

<cfquery name="caller.sel_BlogEntries" datasource="#request.db#"> 
SELECT  blogentry.dateAdded, person.personName 
FROM  blogentry INNER JOIN person ON blogentry.personID = person.personID 
WHERE  blogentry.deleted = 'N' 
ORDER BY blogentry.dateAdded DESC 
</cfquery> 

blogentry.dateAdded是一個MySQL時間戳

感謝

回答

3
WHERE ... 
    AND DATE_ADD(blogentry.dateAdded, INTERVAL 1 DAY) >= NOW() 
+2

雖然這不工作,用在列日期函數可有時干擾指標。更好的選擇可能是:WHERE blogentry.dateAdded> = DATE_ADD(NOW(),INTERVAL -1 DAY)... – Leigh 2010-05-09 11:45:37

相關問題