I am trying to figure out how to select the last 5 rows of a table to display on the main screen when there may be spaces in identifiers. In a database for which there are 1000 rows, I do not want to call all of them to accept the last 5 every time I go to the main screen of my application. The problem is that rows are sometimes deleted in the database for various reasons, therefore, for example, if the last row identifier is 4023, the identifier of the second to the last row can be 4020, so I can’t just use the length and count back. Ideally, this will work as
$get_5_rows = DB::table('rows')->take(5)->get();
Except that instead of collecting the first 5 rows, they will need the last 5.
Thank you for your help! Any help is appreciated!
mario source
share