Solved

CFDIRECTORY search with a query

Posted on 2011-02-24
7
585 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

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

 

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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

CFGRID Custom Functionality Series -  Part 1 Hi Guys, I was once asked how it is possible to to add a hyperlink in the cfgrid and open the window to show the data. Now this is quite simple, I have to use the EXT JS library for this and I achiev…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

785 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