Boyd E. Hemphill wrote:

To all who answered thank you. This answer below is the one that I can
use to convince him what he proposes is not necessarily safe.



I almost always have a timestamp column immediately after my auto_increment'ed primary key column which I use for ordering by insert/update order. To get rows from oldest to most recent, I just:


CREATE TableName (
   ID smallint unsigned not null auto_increment primary key,
   MTime timestamp,
   Data ...
);

SELECT * FROM TableName ORDER BY MTime ASC;

If you want "created" order as well, you can do:

CREATE TableName (
   ID smallint unsigned not null auto_increment primary key,
   MTime timestamp,
   CTime timestamp,
   Data ...
);

INSERT INTO TableName (CTime, Data) values (now(), ...), (now(), ...), ...

That will give you an MTime that's auto-updated based on last modification and a CTime that is the creation timestamp.
--
Michael T. Babcock
http://mikebabcock.ca/


--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to