Staff directory database query fixes

Signed-off-by: Luke Oatham <lukeoatham@gmail.com>