# SQL Query: Searching for a String in the Where command

**URL:** <https://forum.inductiveautomation.com/t/sql-query-searching-for-a-string-in-the-where-command/38841>\
**Category:** Ignition\
**Created:** [September 18, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/sql-query-searching-for-a-string-in-the-where-command/38841 "2020-09-18T16:54:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mreal](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@mreal](https://forum.inductiveautomation.com/u/mreal)\
**Post date:** [September 18, 2020, 4:54pm UTC](https://forum.inductiveautomation.com/t/sql-query-searching-for-a-string-in-the-where-command/38841/1 "2020-09-18T16:54:46Z")

</div>

I’m trying to filter the a column of strings base on if it contains a specific word. Here is a simple example of what I’m drying to do. I’m trying to find the right syntax for the WHERE command.

Select id, strvalue  
From a  
WHERE 1=( ‘Scanner’ in strvalue)

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 18, 2020, 5:11pm UTC](https://forum.inductiveautomation.com/t/sql-query-searching-for-a-string-in-the-where-command/38841/2 "2020-09-18T17:11:05Z")

</div>

Hi! Welcome to the forums! 🙂

You would need to use the LIKE operator

```sql
Select id, strvalue
From a
WHERE strvalue LIKE '%Scanner%'

```

The percent signs act as wild cards. More info in the LIKE operator here:

[https://www.w3schools.com/sql/sql\_like.asp](https://www.w3schools.com/sql/sql_like.asp)

---

<div class="post-metadata">

**Author:** ![mreal](https://avatars.discourse-cdn.com/v4/letter/m/e95f7d/32.png) [@mreal](https://forum.inductiveautomation.com/u/mreal)\
**Post date:** [September 18, 2020, 5:15pm UTC](https://forum.inductiveautomation.com/t/sql-query-searching-for-a-string-in-the-where-command/38841/3 "2020-09-18T17:15:48Z")

</div>

Thank you so much! It did exactly what I needed.

---

<div class="post-metadata">

**Author:** ![MMaynard](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mmaynard/32/3366_2.png) [@MMaynard](https://forum.inductiveautomation.com/u/MMaynard)\
**Post date:** [September 18, 2020, 6:38pm UTC](https://forum.inductiveautomation.com/t/sql-query-searching-for-a-string-in-the-where-command/38841/4 "2020-09-18T18:38:06Z")

</div>

Depending on where in the string your criteria will fall you might want to look at using CHARINDEX, or LEFT/RIGHT in place of the LIKE operator.

```auto
Select id, strvalue
From a
WHERE CHARINDEX('Scanner',[strvalue])>0

```
