Solved

CFDIRECTORY search with a query

Posted on 2011-02-24
7
583 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
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 

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 500 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

This article  is about submitting  form through  ColdFusion.Ajax.submitForm to the action page and send a response back in JSON format which later can be decoded using ColdFusion.JSON.decode. By this way you can avoid the usual page refresh for subm…
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 …
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
Many functions in Excel can make decisions. The most simple of these is the IF function: it returns a value depending on whether a condition you describe is true or false. Once you get the hang of using the IF function, you will find it easier to us…

863 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

Need Help in Real-Time?

Connect with top rated Experts

25 Experts available now in Live!

Get 1:1 Help Now