SQL Query: Searching for a String in the Where command

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)

Hi! Welcome to the forums! :slight_smile:

You would need to use the LIKE operator

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

1 Like

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

1 Like

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.

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