Hello, I’m trying to write a prepared statement for a search query for my database. The problem I’m running into is that a user may choose to leave any number of fields blank on the client form used to perform the search. For example, if a user is searching for a location, they can enter an address, city, state, and zip code on the form. BUT, they can also just enter a single value in the form such as submitting a search with ONLY the city.
I’m having trouble determining how to structure this prepared statement when parameters passed in may be null or missing. I’m very new to databases in general and would appreciate guidance or being pointed in the right direction if this is a common problem which people have implemented in their N1QL queries already.
Some things I’ve tried which don’t feel right at all and haven’t worked (and have resulted in long query times) are things like
REGEX_CONTAINS in the query, but I believe this is going down the wrong path for this problem.
Does anyone have any ideas for this?