Results 1 to 2 of 2

Thread: Fecth Last Record from Table

  1. #1
    Join Date
    Jul 2006
    Posts
    19

    Fecth Last Record from Table

    hi...

    How to fetch the last record from the table without using auto increment field?

    By
    S.Ashokkumar
    India

  2. #2
    Join Date
    Aug 2006
    Posts
    3
    The strict relational model on which relational databases are founded does not support ordering in tables. A table (or more formally, a relation) is a set in the mathematical sense. A set is defined by the elements in it, and there is no concept of ordering.

    To introduce "ordering" in to your table, you will have to add a field that you can sort by. It sounds to me like the field you want is a DATETIME field, which is set by default to the current system time (using NOW()).

    If your timestamp field is "insertdate" then you can do this to get the "last" record:

    SELECT * FROM table ORDER BY insertdate DESC LIMIT 1
    Last edited by nomadmatt; 08-18-2006 at 10:27 PM.

Posting Permissions

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