You might be able to do something like so, never tried it.

declare @this_id int
begin
select @this_id = (id)
from your table
end


insert into table2 (tablerow)
values (@this_id)




"Success is a journey, not a destination!!"



Doug Brown
----- Original Message ----- 
From: "Douglas Jordon" <[EMAIL PROTECTED]>
To: "CF-Talk" <[EMAIL PROTECTED]>
Sent: Friday, March 01, 2002 10:47 AM
Subject: mulitple SQL statements and passing values


> Hi,
> 
> If I want to query a table for an id and then save that id to another 
> table, can I do it in the same SQL statement? If so, how do I refer to 

> the value from the first select? It's something like this:
> 
> <cfquery datasource="#datasource#">
> <cfloop from="1" to="whatever" index="index">
> select id from table_1
> insert into table_2(table_1_id)values(the_id_ just queried)
> </cfloop>
> </cfquery>
> 
> TIA,
> 
> Doug Jordon
> 
______________________________________________________________________
Get Your Own Dedicated Windows 2000 Server
  PIII 800 / 256 MB RAM / 40 GB HD / 20 GB MO/XFER
  Instant Activation · $99/Month · Free Setup
  http://www.pennyhost.com/redirect.cfm?adcode=coldfusionb
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to