# Query with indirect path

**URL:** <https://forum.inductiveautomation.com/t/query-with-indirect-path/14434>\
**Category:** Ignition\
**Created:** [May 31, 2017, 11:53pm UTC](https://forum.inductiveautomation.com/t/query-with-indirect-path/14434 "2017-05-31T23:53:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![michael.palmer](https://avatars.discourse-cdn.com/v4/letter/m/ecccb3/32.png) [@michael.palmer](https://forum.inductiveautomation.com/u/michael.palmer)\
**Post date:** [May 31, 2017, 11:53pm UTC](https://forum.inductiveautomation.com/t/query-with-indirect-path/14434/1 "2017-05-31T23:53:30Z")

</div>

I have a query that I can get to work if I type the path directly, but when I get the path information from a tag, it throws an error. I cant figure out what it thinks is wrong, other than it keeps getting the literal text of the string instead of the value of the tag at that address. I've tried several things and I'm sure its a simple solution, but it won't get the tag value, just the path.

> Exception: Error running query:  
> SQLQuery(query=SELECT step, description, type, jointID, variations, pageNum FROM inverterworkinstructions  
> WHERE stationNum = 1  
> AND pageNum = [default]StationTags/PowerT/Inverter/aaStation1/station/pageNum  
> ORDER BY step, database=FF\_Test\_DB)@5000ms  
> On: InverterStation\_1 (1).Root Container.TablePages.data  
> caused by GatewayException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[default]StationTags/PowerT/Inverter/aaStation1/station/pageNum  
> ORDER BY step' at line 4  
> caused by MySQLSyntaxErrorException: You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '[default]StationTags/PowerT/Inverter/aaStation1/station/pageNum  
> ORDER BY step' at line 4

> Ignition v7.9.2 (b2017041315)  
> Java: Oracle Corporation 1.8.0\_121

Here is the non working :

> SELECT step, description, type, jointID, variations, pageNum FROM inverterworkinstructions  
> WHERE stationNum = {Root Container.Station Name.StationNumber}  
> AND pageNum = [default]{Root Container.Station Name.dataPath}station/pageNum  
> ORDER BY step

And the working query:

> SELECT step, description, type, jointID, variations, pageNum FROM inverterworkinstructions  
> WHERE stationNum = {Root Container.Station Name.StationNumber}  
> AND pageNum = {[default]StationTags/PowerT/Inverter/aaStation1/station/pageNum}  
> ORDER BY step

I believe it has to do with the squiggly brackets, but every time I try to insert them it has a different error. Something about finding an open bracket instead of a closed bracket.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [June 1, 2017, 2:02am UTC](https://forum.inductiveautomation.com/t/query-with-indirect-path/14434/2 "2017-06-01T02:02:35Z")

</div>

You can’t do this in one binding. You will need another property to contain the desired tag value (via an indirect binding) and then include this property in your query.
