Robert, actually, that would not work. As the same query name is used each
time each subsequent query would overwrite the prior one. If you ever need
to execute queries in a loop like that you must be sure to programmatically
adjust the query name as well (perhaps by using a counter).
--- Ben
-----Original Message-----
From: Hinojosa, Robert [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 10, 2000 1:36 PM
To: '[EMAIL PROTECTED]'
Subject: RE: QUERY QUESTION
Put the loop outside the query tag.
<cfloop list="#SI_Item_ID#" index="TheItem">
<cfquery name="qgetitems" datasource="#DSN#">
SELECT *
FROM SI_ITEMS2
WHERE SI_ITEM_ID = #TheITem#
AND SI_Opsrpt_ID = #qgetsi.SI_Opsrpt_ID#
</cfquery>
</cfloop>
Robert Hinojosa
WebDeveloper
512.912.3775
[EMAIL PROTECTED]
www.cirrus.com
-----Original Message-----
From: Kelly Matthews [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 10, 2000 12:14 PM
To: '[EMAIL PROTECTED]'
Subject: QUERY QUESTION
Ok I have 2 queries I am running the first is:
<CFQUERY datasource="#DSN#" name="qgetsi">
SELECT *
FROM SelfInspection
WHERE 0=0
<CFIF (IsDefined("form.date1")) AND (IsDefined("form.Date2"))>
AND SI_dt BETWEEN #CREATEODBCDate(form.date1)# AND
#CREATEODBCDate(form.date2)#
</CFIF>
</CFQUERY>
This runs fine...
Next one is:
<cfquery name="qgetitems" datasource="#DSN#">
<cfloop list="#SI_Item_ID#" index="TheItem">
SELECT *
FROM SI_ITEMS2
WHERE SI_ITEM_ID = #TheITem#
AND SI_Opsrpt_ID = #qgetsi.SI_Opsrpt_ID#
</cfloop>
</cfquery>
This seems to run fine but comes back with ONE record when it should come
back with THREE:
Results:
qgetitems (Records=1, Time=0ms)
SQL = SELECT * FROM SI_ITEMS2
WHERE SI_ITEM_ID = 19 AND
SI_Opsrpt_ID = 5
SELECT * FROM SI_ITEMS2
WHERE SI_ITEM_ID = 13
AND SI_Opsrpt_ID = 5
SELECT * FROM
SI_ITEMS2
WHERE SI_ITEM_ID = 15
AND SI_Opsrpt_ID = 5
It only appears to bring back ONE record however it should bring back 3
because
ID 5 is in there with item id 19,15 and 13 but it seems to only pick up and
display the first one....
Do I need to change my query????
Kelly
----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
----------------------------------------------------------------------------
--
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or
send a message to [EMAIL PROTECTED] with 'unsubscribe' in
the body.
------------------------------------------------------------------------------
Archives: http://www.mail-archive.com/[email protected]/
To Unsubscribe visit
http://www.houseoffusion.com/index.cfm?sidebar=lists&body=lists/cf_talk or send a
message to [EMAIL PROTECTED] with 'unsubscribe' in the body.