【发布时间】:2017-08-31 03:41:09
【问题描述】:
所以我有一个查询,我试图在medication 列或generic 列中获取包含单词citalopram 或单词celexa 的行。
首先我尝试过:
where
( medication ilike '%citalopram%' or
generic ilike '%citalopram%' or
medication ilike '%celexa%' or
generic ilike '%celexa%')
一切都找到了,花花公子,除了,它还选择了包含药物escitalopram的行。所以我更改了查询,使其如下所示:
where
( medication ilike '%citalopram%' or
generic ilike '%citalopram%' or
medication ilike '%celexa%' or
generic ilike '%celexa%') and
medication not ilike '%escitalopram%' and
generic not ilike '%escitalopram%'
现在,果然它消除了包含escitalopram 的行,但现在有时会忽略具有:
- 药物=
CeleXa 40mg oral tablet,通用=null - 药物=
citalopram 40mg oral tablet,通用=null
等等
不知道为什么这可能是问题所在。任何建议将不胜感激!
【问题讨论】:
-
这是因为泛型有一个空值 - 值得一读stackoverflow.com/questions/22818070/…
-
您最好使用正则表达式进行“整个单词”搜索,例如
medication ~* '\ycelexa\y'
标签: postgresql