[英]sql select where column value exists in a text
我正在尋找類似操作員的逆轉。 我有很長的文字和一個單詞的SQL表。 我想選擇文本中存在的單詞。 像這樣的東西:
select word from mytable where word in ('this is a long story')
SELECT word
FROM mytable
WHERE INSTR('this is a long story', word) > 0
函數INSTR是多字節安全的,並且僅當至少一個參數是二進制字符串時才區分大小寫。 希望能幫助到你。
你可以使用CHARINDEX
select word from mytable where CHARINDEX(word , 'this is a long story') > 0
這可以是DB依賴的,例如使用postgreSQL,你可以這樣做:
select word from mytable where word in (select regexp_split_to_table('this is a long story', E'\\s+') );
其他數據庫也有類似的功能。
select word from mytable where 'this is a long story' like '%' || word || '%'
你的意思是這樣的嗎?
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.