Solved

CFDIRECTORY search with a query

Posted on 2011-02-24
7
580 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
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

Hi, I will be creating today a basic tutorial on how we can create a Mail Custom Function and use it where ever we want. The main advantage about creating a custom function is that we can accommodate a range of arguments to pass to the Function and …
I spent nearly three days trying to figure out how incorporate OAuth in Coldfusion for the Eventful API. Hopefully, this article will allow Coldfusion Programmers to buzz through the API when they need to. Basically, what this script does is authori…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

744 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

11 Experts available now in Live!

Get 1:1 Help Now