# Using a property as a table name in SQL query?

**URL:** <https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818>\
**Category:** Ignition\
**Created:** [November 10, 2019, 12:02am UTC](https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818 "2019-11-10T00:02:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![rupej](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rupej](https://forum.inductiveautomation.com/u/rupej)\
**Post date:** [November 10, 2019, 12:02am UTC](https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818/1 "2019-11-10T00:02:34Z")

</div>

I’m using trying to use the following query as the data binding for a table. It works great until I try to use a custom property (which is a string) as the table name. Does anyone know what the correct syntax is to do this? Tried searching but no luck. Thanks!

SELECT T\_Stamp, BatchID  
FROM ‘{Root Container.MySQL\_Table}’  
ORDER BY t\_stamp DESC

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 10, 2019, 2:31am UTC](https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818/2 "2019-11-10T02:31:02Z")

</div>

> [@rupej](#):
>
> SELECT T\_Stamp, BatchID  
> FROM ‘{Root Container.MySQL\_Table}’  
> ORDER BY t\_stamp DESC

Try:

```auto
SELECT T_Stamp, BatchID
FROM {Root Container.MySQL_Table}
ORDER BY t_stamp DESC

```

Tip: using the 'paperclip' icon (insert property value), top right of data binding popup, will create it with the correct syntax

---

<div class="post-metadata">

**Author:** ![rupej](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rupej](https://forum.inductiveautomation.com/u/rupej)\
**Post date:** [November 10, 2019, 2:44am UTC](https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818/3 "2019-11-10T02:44:24Z")

</div>

Thanks Matrix,

I did use the paperclip and it generated the syntax without the quotes. That didn’t work, so the quotes were a guess on my part. Double quotes didn’t work either. Any ideas?

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 10, 2019, 3:07am UTC](https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818/4 "2019-11-10T03:07:49Z")

</div>

I’m a bit unsure what you’re actually trying to achieve here.

Grab a label, place it on the same window, and bind the text property to {Root Container.MySQL\_Table}

Make sure what is displayed on the label equals what you have “when it was working, before you made it dynamic”

I seem to recall that you can’t dynamically use a table name, let me check that

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 10, 2019, 3:21am UTC](https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818/5 "2019-11-10T03:21:04Z")

</div>

![binding](https://us1.discourse-cdn.com/inductiveautomation/original/2X/3/3effc8eb51165d7e62147d891404280e73b647a4.png)

No issues here, it was the column name that can be tricky dynamically (best to use named queries for that)

---

<div class="post-metadata">

**Author:** ![rupej](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rupej](https://forum.inductiveautomation.com/u/rupej)\
**Post date:** [November 10, 2019, 12:55pm UTC](https://forum.inductiveautomation.com/t/using-a-property-as-a-table-name-in-sql-query/29818/6 "2019-11-10T12:55:43Z")

</div>

Welp, I removed the quotes and now it’s working… even though it wasn’t before? I must have changed something between then and now. Thanks for verifying that the drag-and drop worked for you- that made me try removing the quotes again! 👍
