How to generate query based off from user input

Ok, thanks. In my use case i have quite a few combinations of data with the same pattern, which is why i was trying to avoid pushing this logic to the client