# Named query with many conditional WHERE clauses without query string?

**URL:** <https://forum.inductiveautomation.com/t/named-query-with-many-conditional-where-clauses-without-query-string/47880>\
**Category:** Ignition\
**Tags:** ignition80\
**Created:** [June 17, 2021, 12:18pm UTC](https://forum.inductiveautomation.com/t/named-query-with-many-conditional-where-clauses-without-query-string/47880 "2021-06-17T12:18:23Z")\
**Posts on this page:** 1\
**Showing post:** 23

<div class="post-metadata">

**Author:** ![kcollins](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kcollins/32/19646_2.png) [@kcollins](https://forum.inductiveautomation.com/u/kcollins)\
**Post date:** [June 17, 2021, 5:29pm UTC](https://forum.inductiveautomation.com/t/named-query-with-many-conditional-where-clauses-without-query-string/47880/23 "2021-06-17T17:29:43Z")

</div>

It has been a little while since I’ve implemented something like this, so my apologies in advance if the syntax isn’t quite right… What I would do for optional filters is leverage short-circuit evaluation for the parameters and feed `None`/`NULL` when the dropdown is set to `All`. The query would then look something like this:

```sql
SELECT column_a, column_b FROM table
WHERE 1=1
  AND (@for_filter IS NULL OR for_column=@for_filter)
  AND (@rsvp_filter IS NULL OR rsvp_column=@rsvp_filter)
  AND ...

```

This general method lets you bundle in all of the filters (and not have to maintain separate queries) and automatically includes rows for a given where clause where the filter parameter is NULL.

Hope this helps…

---

_[View the full topic](https://forum.inductiveautomation.com/t/named-query-with-many-conditional-where-clauses-without-query-string/47880)._
