ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old October 24th, 2003, 05:10 AM
Danbr Danbr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sertaozinho-SP
Posts: 45 Danbr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
SQL query in an Access DataBase

Hi,

I have a database that lists names of files from pictures of products. For example,

404 is a code. The respective file name is 404_1.jpg. We need the
suffix because we will have another files like
404_02.jpg

and 404_xx.jpg

This database only has file names in one field.

My SQL query string is:

sql = "SELECT foto FROM fotos WHERE foto LIKE '%" & prod & "_%.jpg' "
sql = sql & "ORDER BY foto"

fotos is the table
foto is the field
prod is a string that represents the current product's code
like 404.

However, this SQL string returns
all files for 404 and for 4043

If you could please give me some help about it I would enjoy a lot!

Thanks in advance!

Daniel

Reply With Quote
  #2  
Old October 24th, 2003, 07:27 AM
OldJacques's Avatar
OldJacques OldJacques is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: in Orbit mostly
Posts: 148 OldJacques User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
I'm not positive for Access, but MS SQL Server uses _ as a one character wildcard character, so I suspect the Jet Database Engine does the same on the Web Server.
Something like:
Code:
sql = "SELECT foto FROM fotos WHERE foto LIKE '%" & prod & "[_]%.jpg' "
sql = sql & "ORDER BY foto"
might do the trick in Access too.
I think the first % is also superfluous, and would be better trimming blanks from the source of the product number, if that were the scope of the starting%, because otherwise I would think you would also match 1404_01.jpg

Reply With Quote
  #3  
Old October 24th, 2003, 08:41 AM
Danbr Danbr is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Location: Sertaozinho-SP
Posts: 45 Danbr User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Hi,

Thanks man, but I got errors when the database had more than one picture.
So, I just added a new field in my table
called code, so, I would have pairs:
code-picture name files

It is just the case of matching a variable
prod to the code and then retrieving the files under code.

Thanks anyway!

Daniel

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > SQL query in an Access DataBase


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 4 hosted by Hostway
Stay green...Green IT