Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 5 of 5

Thread: sql question

  1. #1
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    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

  • #2
    Rockstar Coder
    Join Date
    Jun 2002
    Location
    USA
    Posts
    9,074
    Thanks
    1
    Thanked 328 Times in 324 Posts
    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

  • #3
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    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?

  • #4
    Regular Coder
    Join Date
    Jul 2005
    Location
    Oxfordshire, UK
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts
    got it, the working query is:

    SELECT * FROM table where serialno like '%"& request.form("serialnum") &"%';"

  • #5
    Senior Coder Spudhead's Avatar
    Join Date
    Jun 2002
    Location
    London, UK
    Posts
    1,856
    Thanks
    8
    Thanked 110 Times in 109 Posts
    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]


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •