Making a php query that filters words in a MySQL column -
i'm new both php , mysql, forgive me if simple or common question, looked on , couldn't find answer.
basically, i'm building quick search real estate page can type in address , search results bring (and similar results if type in broad "90th street")
right query looks this. ($quicksearch value typed in.)
$query = "select * mlssales (id = '$quicksearch') or (concat_ws(' ',streetnum, streetname) '%$quicksearch%');
now search works me, problem of listings in streetname column contain words "west" or "east" or that. if searches "west 90th street", "300 west 90th street", "300 west 90th", ect. search works. if type "300 90th street" won't results.
how can make search more lenient without making lenient bring in bad results.
what you'd need fulltext search, or manipulate search text make more wildcarded.
your query boils down to
... '%300 90th street'
which works if 3 words next each other 1 space between them.
a full text search treat more as
... '%300%' or '%90th%' or '%street%'
(as hacky example). if can't use fulltext index on table, can try of pre-processing turn each word in search phrase own little 'like' clause. performance suck, because `%...%' clauses can't use indexes, allow arbitrary matches.
Comments
Post a Comment