Andrey.Kyurkchiev Andrey.Kyurkchiev - 5 months ago 10
SQL Question

SQL IN query for approximate values

I am trying to retrieve information from a table using the SQL

IN
function.
I am using the following
select
and my logic is to search for fields containing the abbreviation 'SMS'. However, the query only retrieves values for 'Other Services'

How can I query for only a part of the value in the field?

This is the select function I am using:

select product_id ,product_name
from product
where product_name
IN ('Other Services','%SMS%')

Answer

IN operator doesn't take values with wildcard characters. Instead use LIKE operator.

select product_id ,product_name
from product 
where product_name='Other Services' 
OR product_name LIKE '%SMS%'