Kelly,

You can't execute 3 SELECT statements in a single query that way. You should
combine them into one statement that might look something like this:

<cfquery name="qgetitems" datasource="#DSN#">
                SELECT *
                FROM SI_ITEMS2
                WHERE SI_ITEM_ID IN (#SI_Item_ID#)
                AND SI_Opsrpt_ID = #qgetsi.SI_Opsrpt_ID#
</cfquery>

--- Ben


-----Original Message-----
From: Kelly Matthews [mailto:[EMAIL PROTECTED]]
Sent: Thursday, August 10, 2000 1: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/cf-talk@houseoffusion.com/
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/cf-talk@houseoffusion.com/
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.

Reply via email to