Hi,
If it possible to search in a table for records of which its name contains a search term?
Thanks
Hi,
If it possible to search in a table for records of which its name contains a search term?
Thanks
Sure. There is the CONTAINS
predicate:
... WHERE CONTAINS(name, 'search-term')
There is also the LIKE
operator and some DBMS allow for regular expressions.
SELECT * FROM `my_table` WHERE name LIKE '%my_search_term%'
or
SELECT * FROM `my_table` WHERE CONTAINS(name, 'search')
But be aware that the LIKE statement is very expensive. If you searching through a lot of text, you might want to consider using Sphinx for exemple.
It sounds like what you are looking for is LIKE
-- Get all people with phone numbers starting with 920
SELECT * FROM People WHERE PhoneNumber LIKE '920%'