implement HAS for queries