Hello!

There is a table with three columns.

Table1:

+------------+------------------------------- | id_model | Type | id_model | +------------+------------------------------- | 12 | Седан | 34 | | 13 | Внедорожник | 12 | | 14 | Универсал | 23 | | 15 | Купе | 44 | | 2032 | Седан | 51 | +------------+------------------------------- 

I need to take from this table the values ​​of Type and transfer to another empty table with two columns. In this table, the id is AUTO_INCREMENT and the values ​​of this column respectively must begin with one.

Table2:

  +---------+---------------- | id | Type | +---------+---------------- 

I am writing this query:

 INSERT INTO table2 SELECT type FROM table1 group by type 

In response, the error column count doesn't match value count at row 1 - the number of columns does not match the number of values ​​in row 1.

What needs to be done to match the number of columns and the id in the second table take the AUTO_INCREMENT values ​​starting from one?

    1 answer 1

     INSERT INTO Table2 (Type) SELECT Type FROM Table1; 

    For auto increment (if you haven't configured it yet), make a table with

     ID int NOT NULL AUTO_INCREMENT,