how to create a table structure from another table in mysql
snippet in sql

how to create a table structure from another table in mysql

user9819

CREATE TABLE new_tbl LIKE orig_tbl;  //(creates an empty table only definition is
                                        same.)

mysql select into new table

user9184

CREATE TABLE artists_and_works
  SELECT artist.name, COUNT(work.artist_id) AS number_of_works
  FROM artist LEFT JOIN work ON artist.id = work.artist_id
  GROUP BY artist.id;

how to create a table based on another table in mysql

user1353

Press CTRL+C to copy CREATE TABLE new_tbl [AS] SELECT * FROM orig_tbl;