There is no one-line SQL statement that will do that.

You would use some looping structure if you were passing in a list of IDs,
but if this is all occurring in the same batch, you can select your values
into a temp table, then use an INSERT....SELECT statement to insert based on
your tempTable values.

SELECT ID
 INTO #myTemp
  FROM myTable1 
   WHERE SpecialID = 3

INSERT INTO table3 (ID)
        SELECT ID from #myTemp


Check your SQL 7 help for more info on SELECT INTO and INSERT...SELECT.


-----Original Message-----
From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, March 20, 2001 7:32 PM
To: CF-Talk
Subject: OT: Database Question


Fellow Listers!

All the talk about @@identity encouraged me to ask this question:

Say I:

UPDATE Table2
SET City = 'Oakland'
WHERE ID IN
(SELECT ID FROM MyTable1 WHERE SpecialID = 3)

This is done all within SQL7, and

SELECT ID FROM MyTable1 WHERE SpecialID = 3

is a comma-delimited list of IDs.

How would I do the case where I have Table3
with one column, and I wanted to INSERT the
IDs in it from:

SELECT ID FROM MyTable1 WHERE SpecialID=3

one ID per row, all within SQL7 (no CFAS)?

best,  paul

==============================
N: Paul Smith, Web/Database Droid
A: SupportNet, Inc, 3871 Piedmont Ave, Oakland, CA 94611
    (There, there, there; there's, there, there....)
P: (510) 763-2358          _o
C: (510) 205-6755          _\<,_
F: (510) 763-2370         (_)/(_)
E: [EMAIL PROTECTED]
W: http://www.support.net
"The sun, with all those planets revolving around it and
dependent on it, can still ripen a bunch of grapes as if
it had nothing else to do."  --Galileo
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Structure your ColdFusion code with Fusebox. Get the official book at 
http://www.fusionauthority.com/bkinfo.cfm

Archives: http://www.mail-archive.com/cf-talk@houseoffusion.com/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to