auto_increment

auto_increment

am 07.09.2010 11:29:07 von ron.piggott

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

Re: auto_increment

am 07.09.2010 15:56:17 von Adriano Rodrigo Guerreiro Laranjeira

Hey friend!

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

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

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


Cheers,
Adriano!
> > > > > > > >=20
> On Tue, 7 Sep 2010 05:29:07 -0400
> "Ron Piggott" wrote:
> I am wondering if something like the following
> will work in mySQL:
>=20
> ALTER TABLE `stats` ADD `visits` INT( 25 )
> NOT NULL AUTO_INCREMENT=20
> PRIMARY
> KEY FIRST ORDER BY `initial_access` ASC
>=20
> This particular syntax won't work though.
>=20
> initial_access is a column that contains a unix timestamp.
>=20
> I am trying to get the auto_increment value to be
> added in order of sequence of when the visits occurred.
>=20
> Thank you.
>=20
> Ron
>=20

--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php