Try something like this and loop the or statements for each letter.
<cfset alpha = "a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z">
<cfset range="b-g">
<cfset startpos = listfind(alpha, listfirst(range, "-"))>
<cfset endpos = listfind(alpha, listlast(range, "-"))>
<!--- if endpos is greater than startpos, swap them --->
<cfif startpos gt endpos>
<cfset tmp = endpos>
<cfset endpos = startpos>
<cfset startpos = tmp>
</cfif>
<cfoutput>
<cfif startpos gt 0>
<cfloop from="#startpos#" to="#endpos#" index="i">
<cfif i is startpos>
<cfset clause = "where">
<cfelse>
<cfset clause = "or">
</cfif>
#clause# mycolumn like '#listgetat(alpha, i)#%'<br>
</cfloop>
</cfif>
That should spit out....
where mycolumn like 'b%'
or mycolumn like 'c%'
or mycolumn like 'd%'
or mycolumn like 'e%'
or mycolumn like 'f%'
or mycolumn like 'g%'
-----Original Message-----
From: Les Mizzell [mailto:[EMAIL PROTECTED]
Sent: Thursday, September 01, 2005 8:23 PM
To: CF-Talk
Subject: Where ClientName Like '[a-d]%' - How would you actually do this?
Basically, I'm trying to pull up a number of names where the first
letter is in a RANGE being passed by an url variable.
Something like:
Select from myTABLE
Where ClientName Like '[a-d]%'
....so, it would pull up all clients with names starting with a,b,c, or d.
But, this isn't working.
Ideas?
--
-----------
Les Mizzell
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Logware (www.logware.us): a new and convenient web-based time tracking
application. Start tracking and documenting hours spent on a project or with a
client with Logware today. Try it for free with a 15 day trial account.
http://www.houseoffusion.com/banners/view.cfm?bannerid=67
Message: http://www.houseoffusion.com/lists.cfm/link=i:4:217177
Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4
Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4
Unsubscribe:
http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Donations & Support: http://www.houseoffusion.com/tiny.cfm/54