I have a table A with two column name, description_en
Data
name
----------------
|Hero 1|
----------------
|Hero 2|
----------------
|Hero 3|
----------------
|Hero 4|
description_en
----------------
|Hero 1, if this card|
----------------
|If this card Hero 2|
----------------
|Hero 3 is special|
----------------
|is special card hero 4|
I use php html to make a search box, my input $_GET['search'] is: hero;if this card;is special
$WHERE = "Select * from A where";
$search = "hero;if this card;is special"; // $_GET['search']
$searchs = explode(';', $search);
foreach ($searchs as $valuesearch) {
$phrase= '"'.$valuesearch.'"';
$text_search .= " MATCH(name, description_en) AGAINST ('$phrase' IN BOOLEAN MODE)" ;
}
$search = isset($text_search) ? $text_search : NULL ;
$WHERE .= isset($search) ? $search : NULL;
echo $WHERE;
Query from echo:
Select *
from A
where MATCH(name, description_en)
AGAINST ('"hero"' IN BOOLEAN MODE)
AND MATCH(name, description_en)
AGAINST ('"if this card"' IN BOOLEAN MODE)
AND MATCH(name, description_en)
AGAINST ('"is special"' IN BOOLEAN MODE)
Result above have full 4 rows so the query have no problem, then I try with other input: ero;if this;is specia
If miss somewords in first or last like "is special" to "is specia" or "if this card" to "if this" or "hero" to "ero", then query below have no result, it should be full 4 rows too, what wrong guys?
Select *
from A
where MATCH(name, description_en)
AGAINST ('"ero"' IN BOOLEAN MODE)
AND MATCH(name, description_en)
AGAINST ('"if this"' IN BOOLEAN MODE)
AND MATCH(name, description_en)
AGAINST ('"is specia"' IN BOOLEAN MODE)