S
S
Sergey2017-07-18 17:50:17
PostgreSQL
Sergey, 2017-07-18 17:50:17

LIKE: How to find the desired pattern in a column?

Greetings.
We all know the construction:
SELECT * FROM table WHERE column LIKE '12345%' <- it works :)
Now let's say we have a column in the database with templates ala '12345%', 'asd%' (line by line)
So, this query works:
SELECT * FROM table WHERE 'some_string' LIKE column.
The query above will find all patterns in column that match 'some_string'. This really works.
Now expand the column to an array of values ​​(strings): VARCHAR[]
Let's add some patterns there: {'asd%', 'sdf%', ' %er%'}
And now attention to the question:
I'm trying to do the analogy:
SELECT * FROM table WHERE 'ters' LIKE ANY("column").<- it doesn't work.
Here column is a VARCHAR[] column, i.e. array of strings
Although:
SELECT 'ters' LIKE ANY(ARRAY['asd%', 'sdf%', '%er%']) will be true
So I don't understand why a static array works as it should, but if I instead array I substitute a column with the same values ​​in a line - it does not work.
How to make the right decision?
P.S. postgresql database

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sergey, 2017-07-19
@begemot_sun

https://stackoverflow.com/questions/45189568/like-...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question