One possibility with a more complete result is to use PHP to split your search into separate words, and generate the WHERE clause for you:
<?php
$pesquisa = 'carro verde amassado ';
// Aqui você pode juntar vários campos no concat.
$campo = 'CONCAT( title, " ", description, " ", author)';
// Ou usar um só, mas nesse caso talvez compense um LIKE tradicional
// $campo = 'title';
$palavras = explode( ' ', $pesquisa ); // dividindo as palavras pelo espaço
$palavras = $array_filter($palavras); // eliminando ítens vazios
$where = '';
$cola = 'WHERE ';
foreach ($palavras as $palavra) {
$palavra = trim($palavra); //Removendo espaços em branco
$palavra = mysql_real_escape_string($palavra); // Aqui você sanitiza de acordo com o DB
$where .= $cola.campo.' LIKE "%'.$palavra.'%" ';
$cola = 'AND ';
}
echo htmlentities( $where );
?>
And the result will be:
WHERE
CONCAT( title, " ", description, " ", author) LIKE "%carro%" AND
CONCAT( title, " ", description, " ", author) LIKE "%verde%" AND
CONCAT( title, " ", description, " ", author) LIKE "%amassado%"
(line breaks added for easier reading)
In this way the search will find all these results:
O carro amassado era verde
A carroceria foi atingida por abacates verdes amassados
Verde e amassado carro
Note that although some lines do not have exact results, it's better to have more things than the user can not find what they need. Keep in mind, however, that the price you pay for complexity is a slower search. LIKE
and indexes do not work well together.