Is there a way to for an sql statement to search if a column string with multiple items contains a certain item, but not include a certain item that is a substring. The fol
If you want to require that an item be surrounded by spaces you can add them on either side of your list as well as your term:
select *
from tbltest
where ' '+platform+' ' like '% item %'
Ideally data is not stored in lists, as this searching will not be terribly efficient.
I would do something like this:
select *
from tbltest
where platform like '%item%'
and platform not like '%item.%' -- searching for ASP
and platform not like '%.item%' -- searching for NET
Notice the additional dot before and after item
.
select *
from tbltest
where (platform like 'item%' or platform like '% item%')
and (platform like '%item' or platform like '%item %')
What this does is check whether the item
is surrounded by spaces, the beginning and/or the ending of the string.
A requirement would be that there's no item
with a space and you always split on a space.
Otherwise you'd need another char to split on.