If the ID's are integers, you don't want to put quotes around them.

<CFQUERY NAME="AddLogEntry" DATASOURCE="Software Updates">
   INSERT INTO log (date, tech, software, comments)
   VALUES ('#form.date#', #techs.id#, #software.id#, '#form.comments#')
</CFQUERY>

______________________
steve oliver
atnet solutions, inc.
http://www.atnetsolutions.com


-----Original Message-----
From: Jake Munson [mailto:[EMAIL PROTECTED]] 
Sent: Tuesday, February 19, 2002 7:38 PM
To: CF-Talk
Subject: Foreign keys


Hi guys,

How can I insert the id field of a query into another
table?  What I am wanting is to use the id from one table
as a foreign key in another table.  To do this, I run a
query on the two tables, and then I want to insert the
primary keys (field named id) from these two tables as
foreign keys in the second table.

Below is the code I have written that ins't working.

<cfquery datasource="Software Updates" name="techs">
        SELECT          * 
        FROM            techs
        WHERE   tech='#form.tech#'
 </cfquery>
 <cfquery datasource="Software Updates" name="software">
        SELECT          * 
        FROM            software
        WHERE   software='#form.software#'
 </cfquery>
<CFQUERY NAME="AddLogEntry" DATASOURCE="Software Updates">
        INSERT INTO log (date, tech, software, comments)
        VALUES ('#form.date#', '#techs.id#', '#software.id#',
'#form.comments#')
</CFQUERY>

Thanks.

-Jake

__________________________________________________
Do You Yahoo!?
Yahoo! Sports - Coverage of the 2002 Olympic Games

______________________________________________________________________
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=coldfusiona
FAQ: http://www.thenetprofits.co.uk/coldfusion/faq
Archives: http://www.mail-archive.com/[email protected]/
Unsubscribe: http://www.houseoffusion.com/index.cfm?sidebar=lists

Reply via email to