【发布时间】:2021-06-01 03:36:33
【问题描述】:
我正在努力解决这个问题。我有一列“Column1”,它是 VARCHAR(max) 并且包含很多原始文本。除非满足次要条件,否则我想根据该列中没有特定单词的列过滤掉行。
例如:
返回不存在单词“Final”的所有行。但是,如果“Final”这个词不存在但“Ongoing”这个词确实存在,那么我需要返回这一行而不是隐藏它。
这是我的代码(不工作)
SELECT *
FROM ThisTable
WHERE (
Column1 NOT LIKE '%Final%'
OR Column1 LIKE '%Ongoing%'
)
以下是一些存在的数据示例,以及是否应返回该行。
Row 1: "this project has ended" (return this row)
Row 2: "this project has ended but is ongoing" (return this row)
Row 3: "this project is final." (do not return this row)
Row 4: "This project is final and ongoing" (return this row)
【问题讨论】: