SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    MySQL query - drawing a blank

    How do I write a query that basically pulls only the latest (according to a UNIX_TIMESTAMP field) entry from a database?
    PHP Code:
    SELECT FROM table WHERE date....what
    Sketch
    Aaron Brazell
    Technosailor



  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,265
    Mentioned
    115 Post(s)
    Tagged
    1 Thread(s)
    Select * from table order by datefield desc

    I think the top command also works in MySQL, so you could use the TOP 1 type of syntax in the select to return just one record.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    Prolific Blogger silver trophy Technosailor's Avatar
    Join Date
    Jun 2001
    Location
    Before These Crowded Streets
    Posts
    9,446
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Top 1 is not correct MySQL syntax...

    But the simple query worked...der. Knew it was easy. Thanks.

    Sketch
    Aaron Brazell
    Technosailor




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
  •