Constructing a Database Search Query