[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Is there a mySQL equiv to SQL Server's  select identity(int,1,1) as ...

Posted on 2009-04-15
2
Medium Priority
?
1,193 Views
Last Modified: 2012-05-06
I'm porting a 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.
0
Comment
Question by:studioEtc
2 Comments
 
LVL 51

Accepted Solution

by:
Steve Bink earned 1000 total points
ID: 24154195
Actually, it's a bit of both.  Take a look here:

http://dev.mysql.com/doc/refman/5.1/en/create-table.html#id3240603
0
 
LVL 14

Assisted Solution

by:racek
racek earned 1000 total points
ID: 24154976
SET @i = 0;
INSERT INTO ....
SELECT @i= @i+1 as i, col2 ....
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
In this article, I’ll talk about multi-threaded slave statistics printed in MySQL error log file.
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
In this video, Percona Solutions Engineer Barrett Chambers discusses some of the basic syntax differences between MySQL and MongoDB. To learn more check out our webinar on MongoDB administration for MySQL DBA: https://www.percona.com/resources/we…
Suggested Courses

834 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question