Will lowest autonumber always be first added?

  • Thread starter Thread starter mscertified
  • Start date Start date
M

mscertified

In order to get the first row added to a table, can I just take the lowest
autonumber PK value or do I need a timestamp column?

If I need a timestamp, what is the most efficient query to get the PK value
for the lowest timestamp. Currently I am using:

SELECT ID
FROM tblPortal
WHERE Timestamp IN (SELECT MIN(Timestamp) FROM tblPortal);

I realize this can return multiple rows but I dont care as I just read the
first one.
 
mscertified said:
In order to get the first row added to a table, can I just take the lowest
autonumber PK value or do I need a timestamp column?

I'd say you need the timestamp column. Just in case you ever replicate your
application, since replication changes the Autonumber field to Random, not
Sequential.
If I need a timestamp, what is the most efficient query to get the PK
value
for the lowest timestamp. Currently I am using:

SELECT ID
FROM tblPortal
WHERE Timestamp IN (SELECT MIN(Timestamp) FROM tblPortal);

I don't think you really have any other option!
 
This is a queue table populated by a web page. The Access db reads in the
records on a FIFO basis, hence the need to know the first added.
 
Back
Top