List:General Discussion« Previous MessageNext Message »
From:Michael T. Babcock Date:May 13 2004 2:15am
Subject:Re: urban myth?
View as plain text  
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/
Thread
Create table results in (errno: 121)Tom Brown22 Apr
  • Re: Create table results in (errno: 121)Martijn Tonies22 Apr
  • Re: Create table results in (errno: 121)Tom Brown22 Apr
  • Re: Create table results in (errno: 121)Adam28 Apr
    • urban myth?Boyd E. Hemphill3 May
      • Re: urban myth?Peter J Milanese3 May
      • Re: urban myth?Daniel Clark3 May
      • Re: urban myth?Garth Webb3 May
        • Re: urban myth?Bob Ramsey3 May
          • Re: urban myth?Josh Trutwin3 May
          • Re: urban myth?Garth Webb3 May
          • Re: urban myth?Michael Stassen3 May
            • RE: urban myth?Boyd E. Hemphill3 May
              • Re: urban myth?Anders Karlsson3 May
              • Re: urban myth?Michael T. Babcock13 May
      • Re: urban myth?Josh Trutwin3 May
      • Re: urban myth?Jeremy Zawodny3 May
      • Re: urban myth?gerald_clark3 May
        • Re: urban myth?Peter J Milanese3 May
Re: Create table results in (errno: 121)beacker22 Apr
RE: urban myth?Mike Johnson3 May
Re: urban myth?Udikarni3 May