Insert (multiple) new rows into a table from another table using a subquery?

user3175451

So this is the query I am trying, definately doesnt work.

The subquery returns 3 rows, which I want copied to the new table.

INSERT INTO retired
VALUES (SELECT * from questions where status = 'R');

I was sure looking at it I was doing it wrong, but here is specifically the question:

Do I need to list all the columns separately, or is there a way to tell it just to move the whole row? The tables attributes and columns are identical.

Mariano D'Ascanio

If questions and retired have the same columns (quantity and type), then this should work:

INSERT INTO retired
SELECT * from questions where status = 'R';

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Insert multiple rows from select into another table

From Dev

insert multiple rows mysql from another table

From Dev

Insert new rows into table but copy data from another row in the table

From Dev

select multiple column from one table and insert into another as rows

From Dev

Insert multiple rows with single a query from one table into another in Oracle

From Dev

SQL insert multiple rows from single field in another table

From Dev

INSERT rows multiple times based on a column value from another table

From Dev

Insert multiple rows from other table - "Subquery returns more than 1 row"

From Dev

Insert new rows into table that's connected to another table on Database

From Dev

Insert new rows into table that's connected to another table on Database

From Dev

Fetching Multiple Rows from Table and Adding Them into Another Table and then Remove from Previous Table, Using Checkboxes

From Dev

How to insert multiple rows from a table to another table based on date condition (PHP-MySQL-Query)?

From Dev

looping mysql query to get multiple rows of data from a table and insert into another table

From Dev

Insert multiple rows in one table based on number in another table

From Dev

How to insert multiple rows into one table for each id of another table

From Dev

Insert multiple rows into a MySQL database from a table

From Dev

Insert many rows from a table into one unique row in another table

From Dev

SQL Insert new columns in table B from rows of table A

From Dev

Mysql insert into with multiple id from another table

From Dev

Field involving multiple rows from another table

From Dev

MYSQL - UPDATE multiple rows from another table

From Dev

How to use SQL TRIGGER to insert rows from another table into a new one?

From Dev

Inserting rows in a table from another table using a third table

From Dev

How to insert into a table new records based on info from another table?

From Dev

Insert Data From One Table to Another Table and Add New Values

From Dev

Subtract rows from a table, using subquery which may be empty

From Dev

How to insert different values from same row in multiple rows of a new table

From Dev

How to insert different values from same row in multiple rows of a new table

From Dev

Insert selected value to table from another table multiple times

Related Related

  1. 1

    Insert multiple rows from select into another table

  2. 2

    insert multiple rows mysql from another table

  3. 3

    Insert new rows into table but copy data from another row in the table

  4. 4

    select multiple column from one table and insert into another as rows

  5. 5

    Insert multiple rows with single a query from one table into another in Oracle

  6. 6

    SQL insert multiple rows from single field in another table

  7. 7

    INSERT rows multiple times based on a column value from another table

  8. 8

    Insert multiple rows from other table - "Subquery returns more than 1 row"

  9. 9

    Insert new rows into table that's connected to another table on Database

  10. 10

    Insert new rows into table that's connected to another table on Database

  11. 11

    Fetching Multiple Rows from Table and Adding Them into Another Table and then Remove from Previous Table, Using Checkboxes

  12. 12

    How to insert multiple rows from a table to another table based on date condition (PHP-MySQL-Query)?

  13. 13

    looping mysql query to get multiple rows of data from a table and insert into another table

  14. 14

    Insert multiple rows in one table based on number in another table

  15. 15

    How to insert multiple rows into one table for each id of another table

  16. 16

    Insert multiple rows into a MySQL database from a table

  17. 17

    Insert many rows from a table into one unique row in another table

  18. 18

    SQL Insert new columns in table B from rows of table A

  19. 19

    Mysql insert into with multiple id from another table

  20. 20

    Field involving multiple rows from another table

  21. 21

    MYSQL - UPDATE multiple rows from another table

  22. 22

    How to use SQL TRIGGER to insert rows from another table into a new one?

  23. 23

    Inserting rows in a table from another table using a third table

  24. 24

    How to insert into a table new records based on info from another table?

  25. 25

    Insert Data From One Table to Another Table and Add New Values

  26. 26

    Subtract rows from a table, using subquery which may be empty

  27. 27

    How to insert different values from same row in multiple rows of a new table

  28. 28

    How to insert different values from same row in multiple rows of a new table

  29. 29

    Insert selected value to table from another table multiple times

HotTag

Archive