How to get last 2 days records from table using Mysql Query?By Hardik Savani | July 22, 2016 | | 2921 Viewer | Category : PHP MySql
We may sometimes require to get few days ago records from table like last 2 days, last 3 days, last 10 days or last 15 days etc. Most of developer choose other logic but we can easily get using mysql query(using CURDATE and INTERVAL).
In this example mysql query i have one table "elements" and columns are id, title, description, created_at(timestamps) and update_at, Now we will get all records of last 2 days.so you can fetch fields value using CURDATE and INTERVAL of mysql. In following example you can see how to select data of last two days.
SELECT * FROM `elements`
WHERE created_at >= ( CURDATE() - INTERVAL 2 DAY )
- AngularJS - How to Limit String Length using Filter?
- Laravel 5 mailchimp api integration from scratch with example
- Jquery select2 ajax autocomplete example with demo in PHP
- How to solve 'There are no commands defined in the "cashier" namespace' in Laravel 5
- Jquery tooltip example code with demo using Jquery UI
- Codeigniter 3 - select2 ajax autocomplete from database example with demo
- How to make read more link from string in PHP?
- Codeigniter 3 - Generate PDF from view using dompdf library with example