Question: PHP 5.4 with MySQL  

Building off of this:

```
<?php
   $arr = ...
   $sql = 'SELECT COUNT(*) FROM table WHERE field IN ( ' . implode( ',', $arr ) . ' );';
   $result = $db->query( $sql );
?>

```

How would I display which items of the array ARE NOT in the table?

Answer: 
Instead of returning the count, return the field itself:

```
$sql = 'SELECT field WHERE field IN ' . implode( ',', $arr ) . ' );';
$result = $db->query($sql);
$found = array();
while ($row = $result->fetch_assoc()) {
    $found[] = $row['field'];
}

```

Then you can compare the two arrays:

```
$not_found = array_diff($arr, $found);

```
Just use "NOT IN", if your items is up to 10 elements:

```
<?php
   $arr = array('one','two');
   $filterExisting = "'" . implode("', '", $arr ) . "'";
   $sql = "SELECT COUNT(*) FROM table WHERE field NOT IN (". $filterExisting .")";
   $result = $db->query($sql);
?>

```