0
列またはgeneric
列のいずれかに、citalopram
という語またはcelexa
という語を含む行を取得しようとするクエリがあります。where節がPostgresクエリで適切な行を選択しない
まず私が試した:
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
など
これがなぜ問題なのかわかりません。任意の提案をいただければ幸いです!
を持っているでしょう単語から始まるので、もし
が列の前にスペースを入れて - このHTTPSを読む価値を: //stackoverflow.com/questions/22818070/behaviour-of-not-like-with-null-values –
正規表現を使用して「単語全体」検索を行う方がよい場合があります。 '投薬〜* '\ ycelexa \ y'' –