简体   繁体   中英

How to pass a integer array to not in conditions in PostgreSQL?

I have the following case in PostgreSQL:

    xfields smallint[];
    xfields={1,2,3}

   select fields from table where fieldno not in (xfields);

if i execute the above query it shows error as " operator does not exist: smallint <> smallint[] "

can anyone help me how to pass the values in array in the above query or how to execute the above conditions?

Documentation about it's here Row and Array Comparisons v 9.1 or latest version .

select fields
from table
where fieldno <> all(xfields);

=> sql fiddle demo

You can use array in query by using ALL or ANY functions.

For above query you can use

select fields from table where fieldno <> ALL(xfields);

Check here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM