MySQL: Creating a new table with information from a query

后端 未结 3 1867
情书的邮戳
情书的邮戳 2021-02-03 18:16

In MySQL, I would like to create a new table with all the information in this query:

select * into consultaa2 from SELECT
 CONCAT(    \'UPDATE customers SET
 cus         


        
3条回答
  •  借酒劲吻你
    2021-02-03 18:51

    mysql create new table

    Example from mysql commandline.

    mysql> create table foo(id int, vorta text);
    Query OK, 0 rows affected (0.02 sec)
    

    Insert rows

    mysql> insert into foo values(1, 'for the hoarde');
    Query OK, 1 row affected (0.00 sec)
    

    look what's in there

    mysql> select * from foo;
    +------+----------------+
    | id   | vorta          |
    +------+----------------+
    |    1 | for the horde  |
    +------+----------------+
    1 row in set (0.00 sec)
    

    Create a new table with information from a query

    mysql> create table foo2 select * from foo;
    Query OK, 1 row affected (0.01 sec)
    Records: 1  Duplicates: 0  Warnings: 0
    

    Check if the data moved

    mysql> select * from foo2;
    +------+----------------+
    | id   | vorta          |
    +------+----------------+
    |    1 | for the horde  |
    +------+----------------+
    1 row in set (0.00 sec)
    

提交回复
热议问题