| List: | General Discussion | « Previous MessageNext Message » | |
| From: | joe j | Date: | April 3 2012 8:27pm |
| Subject: | create multiple tables in a single query | ||
| View as plain text | |||
Dear all, I need to create over 100 tables each representing a country. Instead of repeating the commands could I create all tables in one single query? The following are two examples of the tables I'd like to create: 1. for USA CREATE TABLE `US_table_new` SELECT var1, var2` , (case when (country='US') then 1 else 0 end) AS US_citizen FROM `USA_table_old` LEFT JOIN WORLD USING(YEAR); 2. for UK CREATE TABLE `UK_table_new` SELECT var1, var2` , (case when (country='UK') then 1 else 0 end) AS UK_citizen FROM `UK_table_old` LEFT JOIN WORLD USING(YEAR); So what I am trying to get is a script that runs through a list of country names (US, UK, NL, etc) and create tables for each one of them as above. Is this feasible in MySql? Thanks, Joe.
| Thread | ||
|---|---|---|
| • create multiple tables in a single query | joe j | 3 Apr |
| • Re: create multiple tables in a single query | hsv | 4 Apr |
| • Re: create multiple tables in a single query | Rick James | 4 Apr |
| • Re: create multiple tables in a single query | Johan De Meersman | 5 Apr |
| • Re: create multiple tables in a single query | Johan De Meersman | 4 Apr |
| • Re: create multiple tables in a single query | joe j | 4 Apr |
| • Re: create multiple tables in a single query | joe j | 4 Apr |
| • Re: create multiple tables in a single query | Johan De Meersman | 5 Apr |
| • Re: create multiple tables in a single query | joe j | 5 Apr |
| • Re: create multiple tables in a single query | joe j | 5 Apr |
| • Re: create multiple tables in a single query | Johan De Meersman | 6 Apr |
| • Re: create more tables in a single query | hsv | 5 Apr |
| • Re: create multiple tables in a single query | Jan Steinman | 5 Apr |
