我想排除">"
的记录,>
字符前面没有空格。
因此,返回如下记录:
" >"
"I worked on deals >50MM"
但不像:
">"
"I like accoun>ng"
在解析和保存PDF时,我们错误地将某些字符转换为>
,我想跳过这些记录,但不要跳过合法使用>
的记录。合法案件通常有一个空格," "
">"
前面
。当前(但有问题的)解决方案:
select
id, content
from uploads
where (
content ilike '%>%' and
content ilike '% >%'
) or (
content not ilike '%>%'
)
此解决方案的问题在于它将选择同时具有">"和">"的记录。但我想排除">"前面缺少空格的所有内容。
希望这个问题不会太混乱。
只需使用正则表达式:
where not content ~ ' >'
或者也许:
where content ~ '[^ ]>'
另一种可能性:
select id,content from uploads
where id not in (select id from uploads where content like '%>%'
except
select id from uploads where content like '% >%')