List:General Discussion« Previous MessageNext Message »
From:Peter Brawley Date:November 12 2007 9:25pm
Subject:Re: Simple Query
View as plain text  
>I tried this but it is not working. I'm not very 
>familiar with subqueries as you can see. 

>insert into table_2 ( id, value ) values ( (select id from table_1), '1' );

insert into table_2 (id,value)
select id,1 from table_1;

PB


Ben Wiechman wrote:
> I need help writing what is probably a rather simple query.
>
>  
>
> I have two tables. The first contains several columns, but most importantly
> an id column.
>
>  
>
> The second is has two columns, an id that corresponds with the id in the
> first table, and a value.
>
>  
>
> For every row in the first table I'd like to insert a row into the second
> with a set value.
>
>  
>
> I tried this but it is not working. I'm not very familiar with subqueries as
> you can see.
>
>  
>
> insert into table_2 ( id, value ) values ( (select id from table_1), '1' );
>
>  
>
> Ben Wiechman
>
> ben@stripped
>
>  
>
>
>   
> ------------------------------------------------------------------------
>
> No virus found in this incoming message.
> Checked by AVG Free Edition. 
> Version: 7.5.503 / Virus Database: 269.15.30/1126 - Release Date: 11/12/2007 12:56
> PM
>   

Thread
Simple QueryBen Wiechman12 Nov
  • Re: Simple QueryPeter Brawley12 Nov