Create new table from select query result in MySql
In this post let’s learn how to create a new table in MySql using the output of a select query. You can create a new table from any select query output using the following syntax.
CREATE TABLE <table-name> <select query>;
CREATE TABLE master_data_bkp SELECT * FROM master;
This query creates a new table called master_data_bkp from the query select * from master
select * from master_data_bkp;
The above query would return data.
This can be done with any select query not just select all.
create table emp_performance select round(avg(performance),2) as "AVG PERFORMANCE", type as "EMPLOYMENT STATUS", DATE(week) as "WEEK" from emp_performance group by type, week order by week desc;