Search code examples
phpmysqlsearchsql-like

mysql LIKE = imprecise search


I'm using a simple query for my search:

SELECT * FROM table WHERE field LIKE '%term%'

if I have a field = "Company Name 123" and I search for Company 123 the result is null

how can I improve this? it only finds if the term is in sequence


Solution

  • You need to put a % between Company and 123 in order for it to match. You might want to check out full text search functions.