auto_increment

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


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
ron.piggott [ Di, 07 September 2010 11:29 ] [ ID #2047334 ]

Re: auto_increment

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" <ron.piggott [at] actsministries.org> 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
>

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Adriano Rodrigo Guerr [ Di, 07 September 2010 15:56 ] [ ID #2047335 ]
PHP » gmane.comp.php.database » auto_increment

Vorheriges Thema: auto_increment
Nächstes Thema: Select the specific user data from the database