The example I gave you was illustrative only, you can't just copy and paste the code (it is not going to work) you have to adapt it to your context so it can produce a valid sql query, if you need more specific help, please provide a minimal reproducible example (reprex) illustrating your issue. Have a look at this guide, to see how to create one for a shiny app