[thelist] (Probably) Simple SQL Stumper.

Frank framar at interlog.com
Tue May 23 18:48:03 2000


I've got two queries, GetList and GetOneImage.

The first pulls out all the rows matching the conditions. The second 
should do so as well, but only returns the first match, and ignores 
all others. Then in my output, every GetList row returns the same 
GetOneImage.AddrJoin, even though the ID's (the testing conditions) 
are different.

Now I know if I were using an output with the query name 
'GetOneImage' it would return them all. As I look at GetOneImage, my 
assumption is that it fetches all the rows, then picks the one that 
matches the condition out. Why would it not do so for every row 
returned by the first query?

Below are the offending pieces.

<!--- Display the list of records found, if any --->
   <cfquery name="GetList" datasource="#datasource#">
     SELECT  City,PropertyType,ExteriorType,MLSNumber,
         ArchitectureType,QtyRooms,Price,ID
     FROM Address
     WHERE ID > 0

   <cfif len(Form.City)>
     AND  City = '#Form.City#'
   </cfif>

   ...
   </cfquery>

<!--- Return one image who'se AddrJoin corresponds to GetList.ID --->
   <cfquery name="GetOneImage" datasource="#datasource#">
     SELECT ImgLrg, AddrJoin
     FROM Image
     WHERE AddrJoin = '#GetList.ID#'
   </cfquery>



<cfoutput query="GetList">
...

<cfif #GetOneImage.AddrJoin# EQ #GetList.ID#>
   <img src="img/#GetOneImage.imgLrg#">
<cfelse>
   <img src="img/pixel.gif" >
</cfif>

...
</cfoutput>
-- 

Where are we going? Why am I in this handbasket?

Frank Marion                      Loofah Communications
frank@loofahcom.com               http://www.loofahcom.com