How to get last 2 days records from table using Mysql Query?By Hardik Savani | July 22, 2016 | | 957 Viewer | Category : PHP MySql
Share this post:
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 )
- How to copy to clipboard without flash in AngularJS ?
- Laravel 5 generate sitemap using roumen/sitemap package Example
- Laravel 5.2 and AngularJS CRUD with Search and Pagination Example.
- How to add ckeditor with image upload in Laravel ?
- Jquery email autocomplete example with demo using jquery.email-autocomplete.min.js
- Laravel 5 Stripe example using Laravel Cashier from Scratch
- Laravel 5 select with count query with group by example
- Ajax - Cross-Origin Request Blocked in Larave 5?