I am using this basic mySQL query which works great:
$sql = "SELECT * FROM `clients` WHERE
MATCH(`LNAME`) AGAINST('$c') OR
MATCH(`FNAME`) AGAINST('$c') OR
MATCH(`MAIL`) AGAINST('$c') OR
MATCH(`TEL`) AGAINST('$c') "
where $c is the search query. Now this works with all single words/numbers but whenever I add 2 words no results are returned.
For example, if my database has aaaa bbbb in LNAME and I search for “aaaa bbbb” I get nothing back, however when I search for “aaaa” or “bbbb” it does work. I tried adding IN BOOLEAN MODE but it doesn’t make a difference.
Could ayone explain to me how this works? $c is composed of letters, numbers and/or a @
thanks a lot.
First , you should use MATCH AGAINST like this:
Please notice:
and:
You can use
LIKEand it probably will have better results.Example of usage: