we can create a table from an exiting table with all / specific columns by following query,
Example 1:
create table dummy like products.
create table dummy like products.
create table dummy like products.
will create a table dummy as the structure of products table by copying all the rows .
Example 2:
create table dummy select * from products
create table dummy select * from products
create table dummy select * from products
will create a table dummy as the structure of products table by copying the rows.
Example 3:
create table dummy select productid , description, prize
create table dummy select productid , description, prize
create table dummy select productid , description, prize
will create a table dummy with all rows , and the specified columns of pro
Example 4:
create table dummy select * from products limit 0
create table dummy select * from products limit 0
create table dummy select * from products limit 0
will create a table dummy with all the columns and no rows will be copied.
Inserting rows into a table from another table
Suppose we want to copy all / some of the rows from an existing table with other, apply the following query,
Example 1:
Insert into products select * from products
Insert into products select * from products
Insert into products select * from products
will copies all the rows from the products table into products table.