# Filter table with Named Query issue

**URL:** <https://forum.inductiveautomation.com/t/filter-table-with-named-query-issue/18414>\
**Category:** Ignition\
**Tags:** ignition79\
**Created:** [June 12, 2018, 9:08am UTC](https://forum.inductiveautomation.com/t/filter-table-with-named-query-issue/18414 "2018-06-12T09:08:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![f.pinciaroli](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/f.pinciaroli/32/6101_2.png) [@f.pinciaroli](https://forum.inductiveautomation.com/u/f.pinciaroli)\
**Post date:** [June 12, 2018, 9:08am UTC](https://forum.inductiveautomation.com/t/filter-table-with-named-query-issue/18414/1 "2018-06-12T09:08:41Z")

</div>

Hello,

I’m tryng to make a simple filter on a datatable with a named query but I can’t make it works…  
I tryed with a simple query like

SELECT \* FROM products WHERE product\_type=1

I wanto to parameterize the where clause.  
So I created a named query with a String parameter named prod\_type

The named query will be:  
SELECT \* FROM products WHERE :prod\_type

Then I want to bind the :prod\_type parameter to a String property  
Something like if the property value is “1=1” the where clause is ever True  
and if the property value is “product\_type=2” I can see only filtered rows.

The problem is that while testing the parameter of the named query, it works with “1=1” value but it doesn’t work with “product\_type=2” value.

Where is the mistake?

Thanks in advance,  
Federico

---

<div class="post-metadata">

**Author:** ![Sanderd17](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/sanderd17/32/8735_2.png) [@Sanderd17](https://forum.inductiveautomation.com/u/Sanderd17)\
**Post date:** [June 12, 2018, 9:26am UTC](https://forum.inductiveautomation.com/t/filter-table-with-named-query-issue/18414/2 "2018-06-12T09:26:14Z")

</div>

The `:variable` syntax is used to insert parameters, not parts of query strings. This means they will get escaped in SQL (wrapped in quotes and any quotes escaped).

If you want to pass parts of query strings (which is less secure and more likely to have bugs, potentially erasing data), you should use a “QueryString” parameter type, and the `{sqlQueryPart}` syntax.

So you should probably use the following query, and pass on a `prod_type` value:

```auto
SELECT * FROM products WHERE product_type = :prod_type

```

---

<div class="post-metadata">

**Author:** ![f.pinciaroli](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/f.pinciaroli/32/6101_2.png) [@f.pinciaroli](https://forum.inductiveautomation.com/u/f.pinciaroli)\
**Post date:** [June 12, 2018, 9:36am UTC](https://forum.inductiveautomation.com/t/filter-table-with-named-query-issue/18414/3 "2018-06-12T09:36:43Z")

</div>

Thank you for your answer. I supposed it was an escape problem.  
I tried to use querystring type and now It works…even if this is not the best pratice.  
Thank you Sanderd17
