SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have a page that dynamically delivers various data, but when there is no query string, I want it to post the 10 most recent additions. I have a timestamp that is added when data is submitted into the database. I have it in 8 size. [timestamp(8)] What I don't know how to do is compare the timestamps, and find the 10 most recent.

    SELECT * FROM tips WHERE date=???????

    somewhere I need to find the 10 most recent. I also have an auto-incremented column, so the newest tips would also have the highest values in the tip_id column, so how do I select the 10 most recent ones?

  2. #2
    Node mutilating coot timnz's Avatar
    Join Date
    Feb 2001
    Location
    New Zealand
    Posts
    516
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    SELECT * FROM tips ORDER BY date DESC LIMIT 10

    Correct me if I am wrong, but that should select everything from the tips table ordered by the date descending with a limit of 10.

  3. #3
    Your daddy. WALoeIII's Avatar
    Join Date
    Apr 2001
    Location
    USA
    Posts
    526
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    he he

    yep, I got it before I read this. For some reason, I had a brain fart, and completely forgot about limit, and order by. Thanks!


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •