1-- Insert into existing my_table
2INSERT INTO my_table my SELECT * FROM another_table an WHERE an.col1 > 10;
3-- or directely create the new table
4CREATE TABLE my_table AS SELECT * FROM another_table an WHERE an.col1 > 10;
1CREATE TABLE new_tbl LIKE orig_tbl; //(creates an empty table only definition is
2 same.)
1CREATE TABLE artists_and_works
2 SELECT artist.name, COUNT(work.artist_id) AS number_of_works
3 FROM artist LEFT JOIN work ON artist.id = work.artist_id
4 GROUP BY artist.id;