I have a query that is supposed to look through the rota table and select the idstaff an then find all users that are not currently found in that result. As long as idstaff is not null this query works fine however there are cases where idstaff will be NULL. In this case the query fails. Is there any way I can make it work in both instances?
$query = sprintf("SELECT user.*
FROM user
WHERE user.iduser NOT IN (SELECT idstaff FROM rota WHERE idrota=%s)",
$this->db->GetSQLValueString($idrota, "int"));
$result = $this->db->query($this->db->link, $query) or die($this->db->error($this->db->link));