Mysql
 sql >> Base de données >  >> RDS >> Mysql

passer la valeur de la variable PHP dans la clause SQL IN

$array = explode(" ", $words); // GEt each word in array
$in_stmt = "'".implode("','", $array)."'"; // create a string like 'stand','on','in'

MEILLEUR :

$in_stmt = "'".str_replace(" ", "','", $words)."'";

Déclaration MySQL :

$stmt = "select something from sometable WHERE `word` IN (".$in_stmt.") GROUP BY (`p_id`)  LIMIT 1000"