# Using the LIKE statement in SQL

**URL:** <https://forum.inductiveautomation.com/t/using-the-like-statement-in-sql/4734>\
**Category:** General Discussion\
**Created:** [June 29, 2012, 1:56pm UTC](https://forum.inductiveautomation.com/t/using-the-like-statement-in-sql/4734 "2012-06-29T13:56:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ceidson](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@ceidson](https://forum.inductiveautomation.com/u/ceidson)\
**Post date:** [June 29, 2012, 1:56pm UTC](https://forum.inductiveautomation.com/t/using-the-like-statement-in-sql/4734/1 "2012-06-29T13:56:48Z")

</div>

I am trying to run a query on a button, mouse-clicked event.  
The query has the condition WHERE Description LIKE ‘%Stage’.  
When I click the button I get the following error.

ValueError: unsupported format character ‘S’

Is there a way that I can use the % character in this query without ignition looking for a format character?

---

<div class="post-metadata">

**Author:** ![Robert](https://avatars.discourse-cdn.com/v4/letter/r/e95f7d/32.png) [@Robert](https://forum.inductiveautomation.com/u/Robert)\
**Post date:** [June 29, 2012, 2:39pm UTC](https://forum.inductiveautomation.com/t/using-the-like-statement-in-sql/4734/2 "2012-06-29T14:39:48Z")

</div>

Sounds like the python interpreter is trying to process the SQL statement. You probably need to tweak the quoting a bit.

What’s the complete code look like?

---

<div class="post-metadata">

**Author:** ![ceidson](https://avatars.discourse-cdn.com/v4/letter/c/9d8465/32.png) [@ceidson](https://forum.inductiveautomation.com/u/ceidson)\
**Post date:** [June 29, 2012, 4:11pm UTC](https://forum.inductiveautomation.com/t/using-the-like-statement-in-sql/4734/3 "2012-06-29T16:11:43Z")

</div>

That did it. The portion of the query that was giving the problem was:

system.db.runQuery(“SELECT BayType FROM BayTypes WHERE Description LIKE ‘%Stage’”)

I changed it to:

system.db.runQuery(“SELECT BayType FROM BayTypes WHERE Description LIKE '” + “%” + “Stage’”)

and it worked. Thanks.
