List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:July 19 1999 9:04pm
Subject:Re: Using SQL to create new table based on select results
View as plain text  
At 3:27 PM -0500 7/19/99, Webber, William D. wrote:
>Greetings all. I was wondering if there is a way via an SQL statement to
>create a new table and fill it with data from a select statement.
>In Psuedocode:
>select * from MyTable where FirstName like "%A"
>create table MyNewTable( First varchar(20), LastName (20))
>Insert into MyNewTable ( MyNewdata)
>
>I know the basics of select statements, but do not know how to shoot the
>resulting data into a new table. Can you do that?

There sure is, it's a new thing in MySQL 3.23.  The syntax is:

CREATE TABLE new_tbl_name SELECT [rest of normal select statement here]

You don't even have to know the types of the columns your selecting
this way.

--
Paul DuBois, paul@stripped
Thread
Using SQL to create new table based on select resultsWilliam D. Webber20 Jul
  • Re: Using SQL to create new table based on select resultsBenjamin Pflugmann20 Jul
  • Re: Using SQL to create new table based on select resultsPaul DuBois20 Jul
  • Re: Using SQL to create new table based on select resultsSasha Pachev20 Jul
    • Re: Using SQL to create new table based on select resultsJohan Isacsson20 Jul
      • Re: Using SQL to create new table based on select resultsPaul DuBois20 Jul
        • Re: Using SQL to create new table based on select resultsJohan Isacsson20 Jul
    • Re: Using SQL to create new table based on select resultsSasha Pachev20 Jul
    • Re: Using SQL to create new table based on select resultssinisa20 Jul
Re: Using SQL to create new table based on select resultsKevin Smith20 Jul
Re: Using SQL to create new table based on select resultssinisa20 Jul
Re: Using SQL to create new table based on select resultsMichael Widenius2 Aug