Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

CFDIRECTORY search with a query

Posted on 2011-02-24
7
Medium Priority
?
595 Views
Last Modified: 2012-05-11
I am using CFDIRECTORY ACTION LIST to look for files in a directory.   Then I am using a query of queries to limit which files are shown.   The search in the name field is returning things like

# 36784lh_05112010_1139AM.pdf (05/11/2010)
# 36784lh_05112010_1140AM.pdf (05/11/2010)
# 367lh_02142011_1144AM.pdf (02/14/2011)

despite the like is for 367_ or 367lh_...   What am I doing wrong?
<CFdirectory action="list" directory="#application.systempath#memberpdfs\" name="Printers" filter="">


SELECT * FROM Printers
WHERE name like '367_%' or name like '367lh_%'

Open in new window

0
Comment
Question by:digitalwise
  • 4
  • 3
7 Comments
 
LVL 52

Expert Comment

by:_agx_
ID: 34976352
Is there really a # sign in front of the name?  Also, QoQ's are case sensitive so you may have to use lower or upper
 
     WHERE lower(name) like '367_%' OR name like '367lh_%'
0
 

Author Comment

by:digitalwise
ID: 34976364
NO - sorry that came from the copy/paste - the names are
36784lh_05112010_1139AM.pdf (05/11/2010)
36784lh_05112010_1140AM.pdf (05/11/2010)
367lh_02142011_1144AM.pdf (02/14/2011)

But why in the world would the first two show up at all if I am looking for 367_ or 367lh_ since neither of those two meet that criteria??
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34976370
All of those should show up because they both match the criteria. All of them start with '367_%'
0
[Webinar] Cloud Security

In this webinar you will learn:

-Why existing firewall and DMZ architectures are not suited for securing cloud applications
-How to make your enterprise “Cloud Ready”, and fix your aging DMZ architecture
-How to transform your enterprise and become a Cloud Enabler

 

Author Comment

by:digitalwise
ID: 34976391
Is the underscore telling it something because one only of them has an underscore after the 367.    Is there a way to work around that since I really only want the 367lh_ one to get pulled back.
0
 
LVL 52

Accepted Solution

by:
_agx_ earned 2000 total points
ID: 34976392
ie "_" is a special character meaning any one character. So that's why they all match your pattern. If you mean a literal underscore "_", you'll probably need to escape it

http://help.adobe.com/en_US/ColdFusion/9.0/Developing/WSc3ff6d0ea77859461172e0811cbec0e4fd-7ff0.html#WSc3ff6d0ea77859461172e0811cbec0e4fd-7fd7
0
 
LVL 52

Expert Comment

by:_agx_
ID: 34976407
Sorry our posts clashed

ie instead of

     WHERE name like '367_%'

... try

     WHERE name like '367\_%' ESCAPE '\'
0
 

Author Closing Comment

by:digitalwise
ID: 34976408
Thank you!  Totally forgot that it would care about that underscore!
0

Featured Post

[Webinar] Cloud and Mobile-First Strategy

Maybe you’ve fully adopted the cloud since the beginning. Or maybe you started with on-prem resources but are pursuing a “cloud and mobile first” strategy. Getting to that end state has its challenges. Discover how to build out a 100% cloud and mobile IT strategy in this webinar.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Hi. There are several upload tutorials using jquery and coldfusion. I found a very interesting one here Upload Your Files using Jquery & ColdFusion and Preview them (http://www.randhawaworld.com/) . I did keep the main js functions but made sever…
Sometimes databases have MILLIONS of records and we need a way to quickly query that table to return the results me need. Sure you could use CFQUERY but it takes too long when there are millions of records. That is why SOLR was invented. Please …
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …
Suggested Courses

916 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question