# Variable query not match

**URL:** <https://community.grafana.com/t/variable-query-not-match/135349>\
**Category:** Configuration\
**Created:** [October 30, 2024, 12:51pm UTC](https://community.grafana.com/t/variable-query-not-match/135349 "2024-10-30T12:51:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![sadededeoglu](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/sadededeoglu/32/45487_2.png) [@sadededeoglu](https://community.grafana.com/u/sadededeoglu)\
**Post date:** [October 30, 2024, 12:51pm UTC](https://community.grafana.com/t/variable-query-not-match/135349/1 "2024-10-30T12:51:52Z")

</div>

Hello, I have 2 Grafana v11.0.0 and v10.1.4. I get an error when I define variables in both of them.

I am pulling a column with a query. The data in it is like ABC SIGORTA or DFG SIGORTA. When I want to filter with a query, I get the error = Status: 500. Message: db query error: pq: syntax error at or near “SIGORTA”.

query like this . select a.“ACENTE\_ADI” from center\_agenc e a  
where  
a.ay= $ay  
and a.“ACENTE\_ADI” = $ADI

The variable named ay works, but I get this error when there is a space or \_ in the data.

I wonder if there is an error in the data type while defining the variable.  
Thanks for help.

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/e/6/e65a0756c8e79ddf6b688ba9ac6b49a076ebd3d8.png)

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [October 30, 2024, 1:31pm UTC](https://community.grafana.com/t/variable-query-not-match/135349/2 "2024-10-30T13:31:54Z")

</div>

click on query inspector and post what you see there please

---

<div class="post-metadata">

**Author:** ![ebabeshko](https://avatars.discourse-cdn.com/v4/letter/e/9d8465/32.png) [@ebabeshko](https://community.grafana.com/u/ebabeshko)\
**Post date:** [October 30, 2024, 3:25pm UTC](https://community.grafana.com/t/variable-query-not-match/135349/3 "2024-10-30T15:25:12Z")

</div>

Try to use quotes around variable, i.e. something like this:

```auto
select a."ACENTE_ADI" from center_agence a
where
a.ay = ${ay}
and a."ACENTE_ADI" = [[ADI]]

```

or

```auto
select a."ACENTE_ADI" from center_agence a
where
a.ay = ${ay}
and a."ACENTE_ADI" = '${ADI:raw}'

```

---

<div class="post-metadata">

**Author:** ![yosiasz](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/yosiasz/32/45847_2.png) [@yosiasz](https://community.grafana.com/u/yosiasz)\
**Post date:** [October 30, 2024, 4:24pm UTC](https://community.grafana.com/t/variable-query-not-match/135349/4 "2024-10-30T16:24:39Z")

</div>

or just simple add single quotes on ADI

`$ADI`

 ![image](https://us1.discourse-cdn.com/grafana/original/3X/f/4/f4779fdfb49b19088eee4f6f58e7ff2ae4162867.png)

---

<div class="post-metadata">

**Author:** ![sadededeoglu](https://sea2.discourse-cdn.com/grafana/user_avatar/community.grafana.com/sadededeoglu/32/45487_2.png) [@sadededeoglu](https://community.grafana.com/u/sadededeoglu)\
**Post date:** [October 31, 2024, 11:47am UTC](https://community.grafana.com/t/variable-query-not-match/135349/5 "2024-10-31T11:47:02Z")

</div>

Thank you, the second solution you provided solved the problem. ‘${ADI:raw}’
