List:General Discussion« Previous MessageNext Message »
From:Paul DuBois Date:May 11 2002 4:09pm
Subject:Re: search character by character
View as plain text  
At 2:53 -0700 5/11/02, impala wrote:
>Hi
>
>I would like a person to search for a surname. If for
>example you have the surnames "Clark", "Williams" and
>"Wilcox" in the database.
>
>e.g. If the person search just for "Wil" the surnames
>"Williams" and "Wilcox" must be displayed. If the
>person search just for "C" the surname Clark must be
>displayed.
>
>I have something like: SELECT LASTNAME, FIRSTNAME,
>DEPARTMENT FROM EMPLOYEES WHERE LASTNAME LIKE
>'varLastName'
>
>But then you have to enter the whole word. If you
>search for "Clark" you need to type in the whole word
>"Clark".
>
>Just by typing part of the word ,how can I make a
>search in databse possible by using something like
>SELECT in SQL?

Use a SQL pattern and the LIKE operator.  For example "C%"
matches any value beginning with "C".  "Wil%" matches
any value beginning with "Wil".

Some of the other responses you've gotten indicate that
you should use "%var%", but that will match values that
contain var anywhere, not just at the beginning.

Thread
search character by characterimpala11 May
  • Re: search character by characterKim Kohen11 May
  • Re: search character by characterIntruder11 May
  • Re: search character by characterEgor Egorov11 May
  • Re: search character by characterPaul DuBois11 May