CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2002
    Location
    Israel
    Posts
    396

    Need help with SQL search string.

    Hi,
    I am using VB.Net 2008 + SQL server 2005 express.
    I have tables with string fields that used to store names and many text data of any kind, i need to have the ability to find similar words and not just the words the user type to search.
    For example: if i have in my database the text "Hallo" and the user wants to find "Hello" i would like to show him in my results all what i found that contain "Hello" but also "Hallo".
    Can i do that in SQL?
    Thanks

  2. #2
    Join Date
    Dec 2009
    Posts
    596

    Re: Need help with SQL search string.

    Check out the SQL keyword LIKE. You would use a wildcard combination with the 'llo' combination for that particular example. But for the sql to be able to pick up the 'hallo' in a more flexible way in that it would just know that hallo is to be part of the result set; i don't know how.

  3. #3
    Join Date
    Sep 2002
    Location
    Israel
    Posts
    396

    Re: Need help with SQL search string.

    Thanks for reply.
    I use the LIKE today in my code but it’s not what i need, i need SQL code that will give both words "Hello" and "Hallo".
    I need it since the user can save the records with spelling mistakes and if he will try to search without the spelling mistake then he will not get his records.

  4. #4
    Join Date
    Dec 2009
    Posts
    596

    Re: Need help with SQL search string.

    I don't know how if that can even be done. But maybe it can. Hope you get a solution.

  5. #5
    Join Date
    Feb 2005
    Location
    Denmark
    Posts
    742

    Re: Need help with SQL search string.

    Perhaps SOUNDEX or using Full Text searching will help you.

    I'm not sure I'd use either - depending on requirement - myself, but would perhaps look towards 3rd party search engine/tools instead.

  6. #6
    Join Date
    Dec 2009
    Posts
    596

    Re: Need help with SQL search string.

    Isn't it annoying for a user to get results on something they didn't ask for? If the user searched for "skunk" and the computer returns "stunk" because it felt it knew better or that the user mis-spelled the search word; isn't that annoying? It's generally accepted that you get what you ask for. Everyone nowadays are computer literate enough to know that. I feel you're trying too hard. Unless this is a requirement.

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

Featured