mardi 1 décembre 2015

Select whole row and insert it into table_2

Is it possible to select whole row from table_1 (without autoincrement ID) and insert it into another table table_2 which has the same relational scheme as table_1 (the same columns)?

I can do that using for example Python but the table has too much rows to do write a code for that.

So this is the example: table_1:

id | name | age | sex | degree 
1  | Pate | 98  | it  | doc 
2  | Ken  | 112 | male| - 

table_2:

id | name | age | sex | degree

SQLite3:

INSERT INTO table_2 (SELECT * FROM table_1 WHERE id=2);

RESULT: table_2:

id | name | age | sex | degree
1  | Ken  | 112 | male| - 

EDIT:

If this is not possible, it could be done including id so the table_2 would look like:

id | name | age | sex | degree
2  | Ken  | 112 | male| - 

Aucun commentaire:

Enregistrer un commentaire