sql >> Base de Datos >  >> RDS >> Mysql

PHP mysql consulta al juez y no repite la parte de repetición

$sentence = "Marc Gasol is the brother of Pau Gasol";
$words = preg_split("/\s+/", $sentence);

//this will uniqueify your value set
$uniqueWords = array_keys(array_flip($words));

foreach($uniqueWords as $word){
    $parts[] = "name like '%".mysql_real_escape_string($word)."%'";  
}

$where = implode(" OR ", $parts);




$query = mysql_query("SELECT * FROM books WHERE $where "); 
$i = 0;
while($row = mysql_fetch_array($query)) {     
echo $row['name'][$i];     
$i++; 
}