dbTalk Databases Forums  

insert results of select from one table into another table.

comp.databases.mysql comp.databases.mysql


Discuss insert results of select from one table into another table. in the comp.databases.mysql forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
SpreadTooThin
 
Posts: n/a

Default insert results of select from one table into another table. - 02-01-2012 , 12:14 PM






I want to create a new table containing only the results from a select statement of another table. How is that done?

select a, b, c into destTable from sourceTable where a='x';

Does one have to create the destTable or is it created for you with the correct structure?

Reply With Quote
  #2  
Old   
William Colls
 
Posts: n/a

Default Re: insert results of select from one table into another table. - 02-01-2012 , 12:27 PM






On 02/01/2012 01:14 PM, SpreadTooThin wrote:
Quote:
I want to create a new table containing only the results from a select statement of another table. How is that done?

select a, b, c into destTable from sourceTable where a='x';

Does one have to create the destTable or is it created for you with the correct structure?


The insert target must exist before you can even write the query.

Reply With Quote
  #3  
Old   
SpreadTooThin
 
Posts: n/a

Default Re: insert results of select from one table into another table. - 02-01-2012 , 12:32 PM



is there a way to use the describe table statement to create the new table?

Reply With Quote
  #4  
Old   
Hans Castorp
 
Posts: n/a

Default Re: insert results of select from one table into another table. - 02-01-2012 , 12:54 PM



SpreadTooThin wrote on 01.02.2012 19:14:
Quote:
I want to create a new table containing only the results from a select statement of another table. How is that done?

select a, b, c into destTable from sourceTable where a='x';

Does one have to create the destTable or is it created for you with the correct structure?
create table destTable
select a,b,c,
from sourceTable
where a = 'x'

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.