PostgreSQL wildcard LIKE for any of a list of words

前端 未结 5 1175
醉酒成梦
醉酒成梦 2020-11-29 15:47

I have a simple list of ~25 words. I have a varchar field in PostgreSQL, let\'s say that list is [\'foo\', \'bar\', \'baz\']. I want to find any row in my table

5条回答
  •  感情败类
    2020-11-29 16:47

    Actually there is an operator for that in PostgreSQL:

    SELECT *
    FROM table
    WHERE lower(value) ~~ ANY('{%foo%,%bar%,%baz%}');
    

提交回复
热议问题