Search in 2 columns in HubDB with 1 input field

Occasional Contributor



I have ONE inputfield (name). In my HubDB i have ONE Column FIRSTNAME and ONE Column LASTNAME. What i want to achieve is the following:


If i type the firstname or the lastname from the person in the input field, the person should be found (no matter if i type in firstname OR lastname).


What my code looks right now:


{% if %}  {% set queryparam = queryparam ~ &vorname__icontains="|urlencode %}


Now i can just search for firstname.


What i tried is the following:

{% if %}
{% set queryparam = queryparam ~ ("&vorname__icontains="|urlencode)  or




and that one


{% if %}

{% set queryparam = queryparam ~ ("&vorname__icontains="|urlencode) ~ ("||nachname__icontains="|urlencode)


Unfortunately, both examples dont work.

1 Reply 1
HubSpot Moderator

Hi @kove,


I think this is possible, but it will require some fairly custom logic on your end. HubDB doesn't support OR logic in filtering, which is what you're trying to do here. You're basically trying to grab words from an input and match them against either a first name field OR a last name field.


But without using a filter on the table, we can still create some custom logic for this.


{% set names =|split(" ") %}
{% set table = hubdb_table_rows(XXXX) %}
{% for row in table %}
  {% for name in names %}
    {# print out table cells that you need when names match table cell values #}
  {% endfor %} {# end for name in names #}
{% endfor %} {# end for row in table #}


It's not exactly the same thing because you're actually pulling the entire table. But I think this would enable you to accomplish what you're going for. Let me know if that makes sense or if you have any questions about setting it up.


 - Leland

Leland Scanlan

HubSpot Developer Support