I have one table like this

and I want to convert it into table like this

Basically, I want to assign sequential value to column id. Is there any query for that? Also what are the equivalents for rownum in mysql?
I have one table like this

and I want to convert it into table like this

Basically, I want to assign sequential value to column id. Is there any query for that? Also what are the equivalents for rownum in mysql?
You need to use AUTO_INCREMENT
CREATE TABLE animals (
id MEDIUMINT NOT NULL AUTO_INCREMENT,
name CHAR(30) NOT NULL,
PRIMARY KEY (id)
) ENGINE=MyISAM;
You can do it in one way. Make the id column as PRIMARY KEY AUTO INCREMENT and then change the data values of all the 1s with null and then try inserting.
CREATE TABLE `people` (
`id` INT NOT NULL AUTO_INCREMENT,
`name` CHAR(30) NOT NULL,
`profession` CHAR(30) NOT NULL,
PRIMARY KEY (id)
) ENGINE=InnoDB;
And then the SQL like:
INSERT INTO `people` VALUES
(null, 'John', 'Engineer'),
(null, 'Ronny', 'Doctor'),
(null, 'Monty', 'Engineer');
You would do this by creating a PRIMARY KEY and giving it an AUTO_INCREMENT, like this
id int NOT NULL AUTO_INCREMENT,