I use for searching in database similar query to this:
SELECT * , MATCH (field1, field2) AGAINST ('".$keyword."') AS score FROM table_name WHERE MATCH (field1, field2) AGAINST etc...
But when user writes in search box more than one word, it gives all results which are either first word or the second.
Basically, what I want to do, is allow people to search like this:
(keyword1 OR keyword2) AND keyword3 and similar. So, it would find keyword1 and keyword3 or keyword2 and keyword3.
How can I do that?
Assuming you already have a full-text search index on your table, you could instruct that the match should run in boolean mode (you should prob. double check the syntax in the mysql documentation).
Keyword prepended with the ‘+’ sign are mandatory (i.e. returned records must contain both), keywords without ‘+’ matches in OR mode, so the above query is equivalent to (keyword1 && keyword2) || keyword3