Re: [PHP-DB] auto_increment

[email protected] ("Adriano Rodrigo Guerreiro Laranjeira")
Newsgroups php.db
Message-ID <[email protected]>
Hey friend!

I can't see another way to fix your table without a processing (like a 
stored procedure, script, etcetera).

But I believe there is a workaround, which involves a creation of 
another table. See this:
mysql> CREATE TABLE stats2 LIKE stats;
mysql> ALTER TABLE stats2 ADD COLUMN id INT NOT NULL AUTO_INCREMENT, 
ADD PRIMARY KEY(id);
mysql> INSERT INTO stats2 SELECT *, 0 FROM stats ORDER BY 
initial_access;

Don't forget to see the correct type of INT which should be used.


Cheers,
Adriano!
> > > > > > > > 
> On Tue, 7 Sep 2010 05:29:07 -0400
>  "Ron Piggott" <[email protected]> wrote:
> I am wondering if something like the following
> will work in mySQL:
> 
> ALTER TABLE `stats` ADD `visits` INT( 25 )
> NOT NULL AUTO_INCREMENT 
> PRIMARY
> KEY FIRST ORDER BY `initial_access` ASC
> 
> This particular syntax won't work though.
> 
> initial_access is a column that contains a unix timestamp.
> 
> I am trying to get the auto_increment value to be
> added in order of sequence of when the visits occurred.
> 
> Thank you.
> 
> Ron
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.