I am running a query on Postgres table as below:
Column | Type | Modifiers
------------------+-----------------------------+--------------------
status | character varying(16)
select FROM incoming_requests WHERE COALESCE(TRIM(status), '') IN ('','OK','ERROR');
This seems to working fine but below not
select FROM incoming_requests WHERE COALESCE(TRIM(status), '') = ANY ('','OK','ERROR');
ERROR: syntax error at or near ","
LINE 1: ...quests WHERE COALESCE(TRIM(status), '') = ANY (" ","OK","ERR...
select FROM incoming_requests WHERE COALESCE(TRIM(status), '') = ANY (" ","OK","ERROR");
Also suggest if there is any difference in performance using ANY
or IN
Vikrant Singh RanaVikrant Singh Rana
asked Nov 24, 2020 at 20:52
1 Answer 1
No there is no difference
CREATE TABLE incoming_requests ("status" character varying(16) )
✓
select FROM incoming_requests WHERE COALESCE(TRIM(status), '') = ANY (array['', 'OK', 'ERROR']);
✓
db<>fiddle here
answered Nov 24, 2020 at 21:43
lang-sql
ERROR
in the second query.