sql - item is equal to any element in array -


i have table values selected, being checked existence in other query later in procedure. right way of doing this?

here how doing now:

table smt:  s_id | num 1    | 2 1    | 3 2    | 2  table smtable:  id | b_id 1  | 2 2  | 3 

arr_sid should have: {1,2}

declare arr_sid int[];  select s_id     arr_sid     smt     group s_id     having sum(num) <> 0;      select id     val     smtable     b_id = pid , id = any(arr_sid); 

i getting error:

error: malformed array literal: "1" sql state: 22p02 detail: array value must start "{" or dimension information. 

just have select statement clause , in clause use in keyword , second select statement:

select id val smtable b_id = pid , id in (     select s_id     smt     group s_id     having sum(num) <> 0) 

there no need arr_sid variable, , further arrays not standard sql, whereas query portable.


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -