SQL search column where one item in column is substring of another item

前端 未结 3 1623
终归单人心
终归单人心 2021-01-16 09:16

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

3条回答
  •  不知归路
    2021-01-16 10:18

    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.

提交回复
热议问题