Results 1 to 9 of 9

Thread: Search Access DB for string value

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271

    Search Access DB for string value

    Hi,

    I am making a website which I need to search for a a value,

    basically a normal web site search, you know what I mean.

    I have one field call 'searchitem' in a table call tbl_Items this is the field I want to store a running list of words to search through.

    so the field would contain something like:

    book, Lord of the rings, ring, Tolkien etc...

    so if some searched for 'Lord of the rings' it would find that record, I would then want to display it, this I can do myself, its just the search I don't know how to implement

    thanks,
    §tudz

    Studzworld.com - Portfolio

  2. #2
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Passing SQL to the DB along the lines of:

    Select *
    from tbl_items
    where searchitem like '%' + 'Searchword' + '%'

    Would match all of the following:
    searchword
    searchwords
    12searchwordsBlah

    Hope thats what you needed.

  3. #3

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    so this will search through the whole field and match any contained words?

    so if I had these records


    Name:
    fish
    bread
    ball

    type:
    food
    food
    toy

    search:
    edible, fins, gills, eyes
    yeast, edible, wheat, healthy
    round, plastic, yellow

    and sent this query:

    Select Name from tbl_items where searchitem like '%' + 'edible' '%'

    it would return:

    Fish
    Food

    right?
    §tudz

    Studzworld.com - Portfolio

  4. #4
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Yep, If i understand your records properly
    "Select Name from tbl_items where searchitem like '%' + 'edible' + '%'"
    would return:

    Fish
    Bread

  5. #5
    Frenzied Member Memnoch1207's Avatar
    Join Date
    Feb 2002
    Location
    DUH, Guess...Hint: It's really hot!
    Posts
    1,861
    Wildcard characters are different for MS Access and SQL Server...
    MS Access is *
    SQL Server is %
    Being educated does not make you intelligent.

    Need a weekend getaway??? Come Visit

  6. #6
    Frenzied Member Fishcake's Avatar
    Join Date
    Feb 2001
    Location
    Derby, UK
    Posts
    1,092
    Cheers Memnoch i wasn't aware of that.

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    thanks for that
    §tudz

    Studzworld.com - Portfolio

  8. #8

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    that only works if the search data is exectly what is in the field? I want it to be able to match a word from the field?

    such as if data iitem had this in it:

    fish sea shark waves

    and the statement was looking for the word shark if would show that record?
    §tudz

    Studzworld.com - Portfolio

  9. #9

    Thread Starter
    Hyperactive Member
    Join Date
    Jul 2001
    Location
    UK
    Posts
    271
    no matter,

    thank you,

    I have found a how to get it o works

    Thanks again.
    §tudz

    Studzworld.com - Portfolio

Posting Permissions

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



Click Here to Expand Forum to Full Width