ServBit Experts Community
Need help with server administration?
-
Is there a mySQL equiv to SQL Server’s select identity(int,1,1) as …
Posted on August 30th, 2009 No commentsI’m porting aaaaa project from SQL Server to mySQL.
In SQL Server:
“Select identity(int,1,1) as id, a, b, c INTO newTable from oldTable” creates an autoNumbered id column.In MySQL: ?
If there’s no equivalent way, I suppose I could create an empty table with an autoNumber field and then insert into it.
Actually, it’s a bit of both. Take a look here:
http://dev.mysql.com/doc/refman/5.1/en/create-table.html#id3240603
SET @i = 0;
INSERT INTO ….
SELECT @i= @i+1 as i, col2 ….




Recent Comments