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. --------------------------------------------------------------------- Before posting, please check: http://www.mysql.com/manual.php (the manual) http://lists.mysql.com/ (the list archive) To request this thread, e-mail <[EMAIL PROTECTED]> To unsubscribe, e-mail <[EMAIL PROTECTED]> Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php