# Last 20 objects

**URL:** <https://forum.kirupa.com/t/last-20-objects/265712>\
**Category:** programming\
**Created:** [July 11, 2008, 3:52pm UTC](https://forum.kirupa.com/t/last-20-objects/265712 "2008-07-11T15:52:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![stedem](https://avatars.discourse-cdn.com/v4/letter/s/7c8e57/32.png) [@stedem](https://forum.kirupa.com/u/stedem)\
**Post date:** [July 11, 2008, 3:52pm UTC](https://forum.kirupa.com/t/last-20-objects/265712/1 "2008-07-11T15:52:51Z")

</div>

Hello,

I have a tiny own created webshop and i want to add a new function.  
I want to add the function "new product. When people click on the link "new products they see the 20 latest new products.

My database with products has a id value for every product.

Now i want to look up the 20 latest products in the database. So if the latest id is for example 752, it should calc 752 - 20. So in theory it must show till product 732 but taking care of when a product has been deleted (for example product 755)

How could i fix this ?

---

<div class="post-metadata">

**Author:** ![jwilliam](https://avatars.discourse-cdn.com/v4/letter/j/cc9497/32.png) [@jwilliam](https://forum.kirupa.com/u/jwilliam)\
**Post date:** [July 11, 2008, 4:20pm UTC](https://forum.kirupa.com/t/last-20-objects/265712/2 "2008-07-11T16:20:28Z")

</div>

SELECT \* FROM products ORDER BY id DESC LIMIT 20;
