This seems like a good case for using Codeception's helper classes. Basically, any functions you define in the relevant helper will be added to the Guy/Tester class when you run the build command, so you could define something like this in your helper:
public function seeAllRecordsInTheDatabaseHaveValue($table, $key, $value)
{
$db = $this->getModule('Db')->driver; //I believe this is a PDO instance
$query = "SELECT COUNT(*) AS count FROM $table WHERE $key = $value"
//execute the query, get the count
$fullQuery = "SELECT COUNT(*) AS count FROM $table";
//get the full count, compare the two
$this->assertEqual($fullQuery, $query, "The total rows in $table with $key matching $value is not equal to the total number of rows in the table.");
}
Next, run the build command, and in your cept file you should be able to do this:
$I->seeAllRecordsInTheDatabaseHaveValue('table, 'column', 'value');