1

I have data with column name authors type text[] like that: ["Mad Snail", "Jiang Ruotai"]. I am using postgres and typeorm for doing it.

I want to select rows with condition field authors containing values that the user typed. I try to search gg but I got nothing.

For instance, the user typed: Jiang Ruotai. I will get rows with condition authors containing Jiang Ruotai.

How can I do that?

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
  • 1
    Does this answer your question? [Check if value exists in Postgres array](https://stackoverflow.com/questions/11231544/check-if-value-exists-in-postgres-array) – JohnH Apr 01 '23 at 15:24

1 Answers1

0

Use the ANY operator. For example, if the variablesearch_term holds the user's input, then search_term = ANY(authors) is TRUE when search_term matches any of the author's names in the text array.

JohnH
  • 2,001
  • 1
  • 2
  • 13