Will lowest autonumber always be first added?

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.
 
D

Douglas J. Steele

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!
 
M

mscertified

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top