Go Back   CodingForums.com > :: Server side development > ASP

Before you post, read our: Rules & Posting Guidelines

Reply
 
Thread Tools Rate Thread
Enjoy an ad free experience by logging in. Not a member yet? Register.
Old 08-16-2005, 08:35 PM   PM User | #1
robojob
Regular Coder

 
Join Date: Jul 2005
Location: Oxfordshire, UK
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
robojob is an unknown quantity at this point
Question sql question

i know that there are parameters such as like, =, or, etc but is there a contains?

i need to search my database using serial numbers but dont always know the full thing so i would like to search the database for items that contain what i put in the form in the serial number in the database.

any suggestions? i have tried 'like' but that doesnt work with part numbers.

Thanks

Rob
robojob is offline   Reply With Quote
Old 08-16-2005, 08:58 PM   PM User | #2
oracleguy
Rockstar Coder


 
Join Date: Jun 2002
Location: USA
Posts: 9,042
Thanks: 1
Thanked 322 Times in 318 Posts
oracleguy is a jewel in the roughoracleguy is a jewel in the roughoracleguy is a jewel in the rough
When you used 'like' did you include wildcards for it to search with?

It has been a while since I have done this but its like:
serialNumber LIKE '783A382%'

Where the % sign is the wildcard, I think that is the correct character.
__________________
OracleGuy
oracleguy is offline   Reply With Quote
Old 08-16-2005, 09:05 PM   PM User | #3
robojob
Regular Coder

 
Join Date: Jul 2005
Location: Oxfordshire, UK
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
robojob is an unknown quantity at this point
not tried it, didnt know anything about it, i will investigate it using google. not sure how i would incorprate that with the form value from previous page though.... any ideas?
robojob is offline   Reply With Quote
Old 08-16-2005, 09:29 PM   PM User | #4
robojob
Regular Coder

 
Join Date: Jul 2005
Location: Oxfordshire, UK
Posts: 144
Thanks: 0
Thanked 0 Times in 0 Posts
robojob is an unknown quantity at this point
got it, the working query is:

SELECT * FROM table where serialno like '%"& request.form("serialnum") &"%';"
robojob is offline   Reply With Quote
Old 08-17-2005, 12:39 PM   PM User | #5
Spudhead
Senior Coder

 
Spudhead's Avatar
 
Join Date: Jun 2002
Location: London, UK
Posts: 1,856
Thanks: 8
Thanked 110 Times in 109 Posts
Spudhead is on a distinguished road
Just for reference, it varies slightly between databases:

Quote:
Originally Posted by http://www.developerfusion.co.uk/show/674/
Visual Basic gives you several ways to provide pattern-matches in a
search string. Typically, you use pattern-matching characters for two
purposes: to search for strings in a VB application's GUI or variable,
or to look for items within a database, such as Access or SQL. When you
search for pattern matches in a database, however, depending on which
database you're using, different characters perform different matches.

The following list shows the different characters used by each database:

Required Match
Any single character
Access/VB: ? SQLServer: _
Zero or more characters
Access/VB: * SQLServer: %
Any single digit (0-9)
Access/VB: # SQLServer: n/a
Any single character in charlist
Access/VB: [charlist] SQLServer: [charlist]
Any single character not in charlist
Access/VB: [!charlist] SQLServer: [^charlist]
Spudhead is offline   Reply With Quote
Reply

Bookmarks

Jump To Top of Thread


Thread Tools
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

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 09:17 PM.


Advertisement
Log in to turn off these ads.