Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Postgresql Select from values in array

i am converting multiple rows in to a array using array_agg() function, and i need to give that array to a select statements where condition.

My query is,

SELECT * FROM table WHERE id = 
  ALL(SELECT array_agg(id) FROM table WHERE some_condition)

but it gives error, how can i over come it..

like image 749
Sumither S Avatar asked Nov 17 '25 17:11

Sumither S


1 Answers

the error has been cleared by type casting the array, using my query like this

 SELECT * FROM table WHERE id = 
    ALL((SELECT array_agg(id) FROM table WHERE some_condition)::bigint[])

reference link

like image 71
Sumither S Avatar answered Nov 19 '25 08:11

Sumither S