Mysql - Create mysql table from query info, Create mysql table from query info
Create mysql table from query info
A new mysql table can be created with the information what we fetch from from select query, Below example will provide you the details for creating a new mysql table by using the select query. Herw you fetch the table info and create a new table by using the same info.mysql> create table foo(id int, name text); Query OK, 0 rows affected (0.02 sec)
Insert values into the table created:
mysql> insert into foo values(1, 'John Smith'); Query OK, 1 row affected (0.00 sec)
View the content of the table using select query:
mysql> select * from foo; +------+----------------+ | id | name | +------+----------------+ | 1 | John Smith | +------+----------------+ 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
View the content of the new tabel using select query:
mysql> select * from foo2; +------+----------------+ | id | name | +------+----------------+ | 1 | John Smith | +------+----------------+ 1 row in set (0.00 sec)
The topic on Mysql - Create mysql table from query info is posted by - Danial
Hope you have enjoyed, Mysql - Create mysql table from query infoThanks for your time