A slightly more elegant SQL filtering mechanism