Solved

CFDIRECTORY search with a query

Posted on 2011-02-24
7
588 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

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 …
PROBLEM: How to add your own buttons to the bottom toolbar with paging info ( result count ). While creating a cfgrid, I ran into an issue where I wanted to embed my own custom buttons where the default ones ( insert / delete / etc… ) are for aes…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

831 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