Home → Admin Manual → System Administration → Custom SQL WHERE Clause in Filters
4.1. Custom SQL WHERE Clause in Filters
Updated: 9 Sep 2026, 10:34 AM EDT
Administrators have a Custom "where" clause (SQL) condition, under Advanced in the condition dropdown. It takes a raw SQL WHERE expression for cases the condition builder cannot express — see Filter Conditions Reference for everything the builder does cover before reaching for this.
It is genuinely administrator-only — the option is hidden from other staff and the save is rejected server-side as well.
Four cautions:
Invalid SQL breaks the filter. The expression is inserted into the query exactly as written. There is no validation and no parameter binding.
Wrap your clause in parentheses. Conditions are joined to each other without brackets of their own, so a clause containing a top-level OR silently changes the meaning of the whole filter. Written as xCategory = 3 OR xCategory = 7 in a Match all filter, it lands in the query as … AND xCategory = 3 OR xCategory = 7 AND … — and because AND binds more tightly than OR in SQL, the filter's other conditions stop constraining the results the way you intended. Written as (xCategory = 3 OR xCategory = 7) it behaves. Parenthesise anything more complex than a single comparison.
It obeys the filter's Match all/any like any other condition. In a Match any filter the clause is OR-ed with everything else, which widens the results rather than narrowing them. This surprises people who expect a WHERE clause to be restrictive. See How Filter Conditions Work.
Mind the database platform. HelpSpot runs on both MySQL and SQL Server, and their syntax differs. A clause that works on one will not necessarily survive a migration or work on another instance you manage.