5

In PostgreSQL I am trying to convert an array to a list say I have an array: v_arr

I want to use this array in the below query in Postgres:

Select * 
from table_name 
where column_name in (v_arr)
2
  • Please edit your question (by clicking on the edit link below it) and add the complete source code of your function. edit your question do not post code in comments. Commented Oct 11, 2018 at 17:08
  • any solutions so far? Commented Aug 19, 2021 at 0:00

2 Answers 2

5

You could use unnest

SELECT * 
FROM table_name 
WHERE column_name IN (SELECT unnest(v_arr));

https://www.postgresql.org/docs/current/static/functions-array.html

Sign up to request clarification or add additional context in comments.

1 Comment

the above returned nothing. Its returning null Alberto
3

You could use = ANY:

Select * from table_name where column_name = any (v_arr);

db<>fiddle demo

2 Comments

the above returned nothing. Its returning null
@StackAcc Please post your actual data.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.