Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 4 of 4
  1. #1
    Regular Coder
    Join Date
    Feb 2005
    Location
    Tokyo, Japan
    Posts
    151
    Thanks
    0
    Thanked 0 Times in 0 Posts

    SELECT (most recent record) FROM table_name WHERE name="whatever";

    Right now I have a simple querly that will select all columns for any record WHERE name = "whatever "

    i.e.

    SELECT * FROM table_name WHERE name="bob";

    if bob has 5 records, all five records will display...

    Is there a way to SELECT only the most recent record for bob?

    Thanks,

    Yak

  • #2
    New Coder
    Join Date
    Apr 2005
    Posts
    72
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I think adding "LIMIT 0, 1" to the end of your query should do it.

    If you have further problems selecting the right record, you can also use ORDER BY and the ASC and DESC modifiers

  • #3
    teh Moderatorinator
    Join Date
    Sep 2004
    Location
    USA
    Posts
    2,472
    Thanks
    4
    Thanked 40 Times in 40 Posts
    You can use the DISTINCT keyword and use an order by on a timestamp field.

  • #4
    Regular Coder
    Join Date
    Oct 2002
    Posts
    380
    Thanks
    0
    Thanked 0 Times in 0 Posts
    You need some way of identifying the most recent record - a timestamp or an auto-increment field, for example. If you don't have this, then it's difficult.


  •  

    Posting Permissions

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