For the search bar, I need to select each entry, where (in the field the search is performed) there is at least one word starting with the given text.
For example:
'John Doe'
Search strings should be selected, for example:
'joh'
'do'
'JOHN doe'
Unable to choose not with
'ohn'
'oe'
I need (possibly) to avoid full-text search.
What I found to work,
$query = 'SELECT * FROM MYTABLE WHERE SEARCHFIELD LIKE "' . $searchText . '%"'
. 'OR SEARCHFIELD LIKE "% ' . $searchText . '%"'
I ask if there is a better way to do this.
(for the βbetter wayβ I mean better performance or the same performance, but more elegant)
Also, as the query is created with a prepared statement, how do I add unescape LIKE metacharacters to the search bar?
Paolo