Pull most recent record

Results 1 to 6 of 6

Thread: Pull most recent record

  1. #1
    coopetj Guest

    Default Pull most recent record

    I want to pull the most recent entry into a database.<BR><BR>Should I use the "like" and compare it to the current date?<BR><BR>Is there a SQL command to pull the most current or recent record?

  2. #2
    coopetj Guest

    Default RE: Pull most recent record

    Pull it from a database not into a database.<BR>

  3. #3
    Join Date
    Dec 1969

    Default RE: Pull record with highest date

    The following query will return records so that records with latest date in the datecolumns appears first.<BR><BR>select * from t<BR> order by dateColumn desc<BR><BR>then set the maxrecords property for the recordset if you wish to restrict the number of records retrieved. <BR>A relational DBMS can only retrieve data depending on the values in the columns, they do not keep track of in which order record are inserted.

  4. #4
    coopetj Guest

    Default RE: Pull record with highest date

    Thank you. I forgot that you can set the max number of records returned. Thanks again.

  5. #5
    Ron Elliott Guest

    Default Use primary key

    If you have a primary key(such as catalogID):<BR><BR>Dim rsM, rs, id<BR>set rsM = Server.CreateObject("ADODB.Recordset")<BR> rsM.open "SELECT max(catalogID) from Products", dbc<BR>id = rsM(0)<BR>set rs = Server.CreateObject("ADODB.Recordset")<BR> rs.open "select * from Products where catalogID = "&id&"", dbc, adOpenKeyset, adLockOptimistic<BR>

  6. #6
    peterjl@austec.net.au Guest

    Default Better still: do it all in the sql

    select top 1 * from t<BR>order by dateColumn desc<BR>

Posting Permissions

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