Filter Table Options

I was, uhh, just seeing if you were paying attention! :grimacing:
In that case, how would you return everything if no values are supplied? Would you just construct the query based on whether there are values or not?

Yes. No values to match generally means no results to retrieve.

You can build up complex where clauses on the fly with question marks in the correct places, then join them with ' And '.join(wherelist) or such, while building the corresponding parameter list at the same time. If the list of wheres is empty, omit the where clause entirely from the final SQL. The point is that dynamic SQL is fine if the strings to be assembled are constants and placeholders. Any real values travel in the parameter list to those placeholders.

2 Likes