# Trying to use a variable in HubDB query

**URL:** <https://community.hubspot.com/t/trying-to-use-a-variable-in-hubdb-query/42701>\
**Category:** CMS Development\
**Tags:** hubdb\
**Created:** [August 23, 2021, 10:29am UTC](https://community.hubspot.com/t/trying-to-use-a-variable-in-hubdb-query/42701 "2021-08-23T10:29:35Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![wmflan39](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wmflan39/32/45434_2.png) [@wmflan39](https://community.hubspot.com/u/wmflan39)\
**Post date:** [August 23, 2021, 10:29am UTC](https://community.hubspot.com/t/trying-to-use-a-variable-in-hubdb-query/42701/1 "2021-08-23T10:29:35Z")

</div>

I’m passing a value to a page via a URL prameter ?lead\_origin=soldering and defining ‘process’ per

{% set process = request.query\_dict.lead\_origin %}.

I need to use the value stored in {{process}} in a HubDB query to select the row matching that value and to return data in some columns per (‘tableID’ substituted for actual ID):

{% set table\_id = [tableID]%}\<br\>{% for row in hubdb\_table\_rows([tableID], “name={{process}}”) %}  
\<h1\>{{row.heading}}\</h1\>  
\<p\>{{row.value\_prop}}\</p\>  
{% endfor %}

Doesn’t work; returns nothing. Any ideas what I’m doing wrong?

WmFlanigan

---

<div class="post-metadata">

**Author:** ![Kevin-C](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/kevin-c/32/34570_2.png) [@Kevin-C](https://community.hubspot.com/u/Kevin-C)\
**Post date:** [August 23, 2021, 2:26pm UTC](https://community.hubspot.com/t/trying-to-use-a-variable-in-hubdb-query/42701/2 "2021-08-23T14:26:16Z")

</div>

Hey @wmflan39

When using a hubl variable inside a funciton you don’t need to use the double brackets, you just need to concatenate the query into a string:

```lia-code-sample
{% for row in hubdb_table_rows([tableID], "name="~process) %}
…

```

---

<div class="post-metadata">

**Author:** ![wmflan39](https://d10pqhm3lwygmk.cloudfront.net/user_avatar/community.hubspot.com/wmflan39/32/45434_2.png) [@wmflan39](https://community.hubspot.com/u/wmflan39)\
**Post date:** [August 23, 2021, 2:31pm UTC](https://community.hubspot.com/t/trying-to-use-a-variable-in-hubdb-query/42701/3 "2021-08-23T14:31:52Z")

</div>

Kevin-C,

Sweet! Thanks very much. I’lll give it a try.

WmF
