0

I'm trying to understand how to do a MySQL query. It needs to look at all records, then sort them by date and then only return in $results the first 15 (in order w/ most recent first)

Date field is 'date_version' and it's stored as date and is formatted in database as: yyyy-mm-dd

Simple results showing all - how do I modify it?

// get all entries from database table Mytable;
$results = DB::query("SELECT * FROM Mytable");
parti
  • 205
  • 3
  • 15
  • It works with SQL which is then used by meekroDB. So don't search/ask for meekroDB, just ask about the SQL. – hakre May 20 '14 at 17:53
  • The duplicate question should answer that to you. If not, please comment here what is unclear about the problem to you. – hakre May 20 '14 at 17:58

1 Answers1

2

It should be -

$results = DB::query("SELECT * FROM Mytable ORDER BY date_version DESC LIMIT 15");
Jay Blanchard
  • 34,243
  • 16
  • 77
  • 119