$string = "'1', '2', '3'"; $string = str_replace("'", '', $string); $sql = "SELECT * FROM name WHERE id NOT IN ( $string ) LIMIT 10 ";