How to select data from a table recorded only in the last three days (use PHP, MySQL)

I wrote data to the 'date' field with the mysql NOW () function. I want to SELECT the data that was recorded the last three days (today, yesterday and the day before yesterday), but do not intend to do this. I am trying my code as it should, please help.

SELECT * FROM tlb_students WHERE date ...? ... ORDER BY date DESC LIMIT 20

+4
source share
4 answers
SELECT * FROM tlb_students WHERE date >= NOW() - INTERVAL 3 DAY ORDER BY date DESC LIMIT 20 
+5
source
 WHERE date >= ( CURDATE() - INTERVAL 3 DAY ) 
+4
source
 WHERE date >= subdate(NOW(), 2) 
+2
source

Another way to do this:

 SELECT * FROM tlb_students WHERE date < DATE_ADD(CURDATE(),INTERVAL -3 DAY) 
+1
source

All Articles