What I think you're really looking for is a SQL Join,


<cfquery name="query1" datasource="datasource">
     SELECT PK, FK foo,
        FROM bar, barchild
        WHERE FK=PK
</cfquery>


BUT... try this too if thats not the case, this will work for numeric vals
on query1... if your ID is text, append quotes aroung each list item.

<cfquery name="query1" datasource="datasource">
     SELECT RecordID,  foo
    FROM bar
</cfquery>

<cfset mycount =0>
<cfloop query=query1>
    <cfset myval="" & MyVal & RecordID> <!--- the "" keeps it a string --->
    <cfset mycount=mycount+1>

   <!--- Append a comma unless its the last record --->
    <cfif mycount NEQ query1.recordcount>
        <cfset myval=myval & ",">
    </cfif>
</cfloop>


<!--- now you can do the second query ---->

<cfquery name="query2" datasource="datasource">
     SELECT  foo FROM bar where fooID in (#MyVal#)
</cfquery>


Dan Newsome
Pop Fizz Berserk Design
(BTW, We're looking for projects)




----- Original Message -----
From: <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Wednesday, July 05, 2000 2:58 PM
Subject: Re: Query Question


>
> I'm sure that this isn't the best solution but this will work
>
> Query 1
>
> <cfquery name="query1" datasource="datasource">
> SELECT RecordID,  foo
> FROM bar
> </cfquery>
>
>
> Query 2
>
> <cfoutput query="query1">
> Insert query
> <cfquery name="insert" datasource="datasource">
> INSERT INTO bar2 (RecordID, foo2)
> VALUES(#RecordID#, '#foo#')
> </cfquery>
>
> update
>
> <cfquery name="update" datasource="datasource">
> UPDATE bar2
> SET foo2 =  '#foo#'
> WHERE RecordID = #RecordID#
> </cfquery>
>
> </cfoutput>
>
> --Kat
>
> ====================
> Katrina Chapman
> Consultant
> Ameriquest Mortgage
>
>
>
>                     "Henry, David
>                     B"                   To:
"'[EMAIL PROTECTED]'" <[EMAIL PROTECTED]>
>                     <dbhenry@indi        cc:
>                     ana.edu>             Subject:     Query Question
>
>                     07/05/00
>                     02:00 PM
>                     Please
>                     respond to
>                     fusebox
>
>
>
>
>
>
> I am using a database query which gets a value from a URL Parameter and
> returns all of the records associated with that Parameter.  So far, so
> good.
> Next, I want to use the RecordID from the first query in a second query.
> The problem is that when I try it, I only get the first recordID to appear
> in the Second Query.
>
> Does this make sense?  If so, can anyone help.
>
> Thanks,
>
> David
> --------------------------------------------------------------------------
----
>
> To Unsubscribe visit
> http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
> send a message to [EMAIL PROTECTED] with 'unsubscribe' in
> the body.
>
>
>
>
> --------------------------------------------------------------------------
----
> To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
>


------------------------------------------------------------------------------
To Unsubscribe visit 
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/fusebox or send a 
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.

Reply via email to