Question: Let's say my resulting recordset is as follows:

```
Emp_ID    ID    Ability    Rating
------    --    -------    ------
NULL      DRI   Driving    NULL
NULL      TYP   Typing     NULL
NULL      GRA   Graphics   NULL
NULL      VID   Video      NULL
NULL      GAM   Gaming     NULL

```

while another case could be:

```
Emp_ID    ID    Ability    Rating
------    --    -------    ------
15        DRI   Driving    7
15        TYP   Typing     6
15        GRA   Graphics   8
15        VID   Video      7
15        GAM   Gaming     10

```

or:

```
Emp_ID    ID    Ability    Rating
------    --    -------    ------
22        DRI   Driving    4
NULL      TYP   Typing     NULL
NULL      GRA   Graphics   NULL
22        VID   Video      8
22        GAM   Gaming     5

```

What's my **least costly** way in PHP to check if `Emp_ID` is all `NULL` like the first one?

`Emp_ID` is `BIGINT(20) UNSIGNED` (and `Rating` is `TINYINT(2) UNSIGNED`) in MySQL. The recordset is returned by `$wpdb_custom->get_results()`.

Answer: 
```
$all_null = true;
foreach($wpdb->get_results() as $row) {
    if(!is_null($row['Emp_ID'])) {
        $all_null = false;
        break;
    }
}

```

Since you can't edit the query, the best you can do is just iterate over the results checking for null. But the important thing is to `break` when you find a non-null row. At that point you know that not all rows are null, so don't bother iterating over the remaining rows.
The php way is to iterate the array

```
$аll_null = TRUE;
foreach($result as $one) $аll_null = $аll_null AND ($one->Emp_ID === NULL);
var_dump($аll_null);

```

Edit:

I'm sure that the method `get_results` also uses iteration so you can extend your `$wpdb_custom` class with another method like this:

```
public function get_results_custom($key, $test, &$result)
{
  * * *
  $result = TRUE
  while($row = do_some_iteration())
  {
    $result = $result AND $test($row->$key);
    * * *
  }
}

```

so now you can do:

```
$all_null = TRUE;
$my_data = $wpdb_custom->get_results_custom('Emp_ID', 'is_null', $all_null);
if($all_null) ...

```