# MySQL DB Query

**URL:** <https://forum.inductiveautomation.com/t/mysql-db-query/10344>\
**Category:** Ignition\
**Created:** [August 14, 2015, 1:47pm UTC](https://forum.inductiveautomation.com/t/mysql-db-query/10344 "2015-08-14T13:47:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [August 14, 2015, 1:47pm UTC](https://forum.inductiveautomation.com/t/mysql-db-query/10344/1 "2015-08-14T13:47:20Z")

</div>

I’m pulling data on a tag i’m taking history on from a database table and the query looks like this

SELECT \*  
FROM sqlth\_te  
WHERE tagpath = ‘_a\_name_/goldtest7\_7simulator/sensor {Root Container.Text Field.text}/sensor {Root Container.Text Field.text}/humidity’

I’m just looking to pull the data from a specific tag and I’m pretty sure that the query is correct. My question is more about where is the history stored for tags? My query is only returning one row. Any thoughts?

---

<div class="post-metadata">

**Author:** ![Pat](https://avatars.discourse-cdn.com/v4/letter/p/8491ac/32.png) [@Pat](https://forum.inductiveautomation.com/u/Pat)\
**Post date:** [August 14, 2015, 4:11pm UTC](https://forum.inductiveautomation.com/t/mysql-db-query/10344/2 "2015-08-14T16:11:36Z")

</div>

Use the scripting function system.tag.queryTagHistory(). Querying the tag history database directly is not as easy as one would think.

---

<div class="post-metadata">

**Author:** ![alewayhar](https://avatars.discourse-cdn.com/v4/letter/a/ebca7d/32.png) [@alewayhar](https://forum.inductiveautomation.com/u/alewayhar)\
**Post date:** [August 14, 2015, 4:31pm UTC](https://forum.inductiveautomation.com/t/mysql-db-query/10344/3 "2015-08-14T16:31:40Z")

</div>

Thank you! That looks much easier! In addition to that, I also just discovered/rediscovered that there is a tag history option under property bindings, so I think I may be able to use that as well!
