if your "query" query returns just one row of data (which it looks like it does), then you do not even need your <cfset statelist = #query.state#> (and, btw, no need for those # in cfset statement!)
this should do what you want:
<cfloop list="#query.state#" index="state">
<cfquery ...>
SELECT *
FROM log
WHERE sate = <cfqueryparam cfsqltype="cf_sql_varchar"
</cfquery>
</cfloop>
furthermore, it may very well be possible for you to run just ONE query instead of multiple queries inside a cfloop... it all depends on what the query returns and how you use that data...
but you can run ONE query with IN operator in WHERE clause to select all data from LOGS table for all states returned by your first query using this sql:
<cfquery ...>
SELECT *
FROM log
WHERE state IN (<cfqueryparam cfsqltype="cf_sql_varchar"
</cfquery>
Azadi
Main Topics
Browse All Topics





by: SidFishesPosted on 2009-10-09 at 10:07:12ID: 25536770
like so
,ID,IL,IN, IA,KS,KY,L A,ME,MD,MA ,MI,MN,MS, MO,MT,NE,N V,NY,NH,NJ ,NM,ND,OH, OK,OR,PA,R I,SC,SD,TN ,TX,UT,VT, VA,WA,WV,W Y,WI,DC">
<cfoutput>
<cfset statelist =" AL,AZ,AR,CA,CO,CT,DE,FL,GA
<cfloop list="#statelist#" index="x">
Select * from log
where state = '#x#'
<br>
</cfloop></cfoutput>
(removed the cfquery for demo)