Jump to content

Last db items?


Kyle123

Recommended Posts

What he said. But, you will need a field to use for ordering the records to achieve this. If there is an auto-incrementing ID field you can use that. Otherwise you would probably want to create a timestamp field that is automatically populated when the record is created. If you have an existing field of either type you can use that. If not, you can add either one such that you wouldn't have to change any of your existing code since they would be handled automatically by the database.

 

The query to get what you need would look something like this

SELECT field1, field2, field3
FROM table_name
ORDER BY order_field DESC
LIMIT 5

 

Where 'order_field' is the auto-incrementing int or timestamp field.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.