Answer the question
In order to leave comments, you need to log in
How to properly write condition for Postgresql view?
Hello, friends.
DBMS Postgresql 9.3.
Create view with multiple condition
CREATE OR REPLACE VIEW rastitelnos_line_10000 AS
SELECT *
FROM rastitelnos_line
WHERE (rastitelnos_line.objectkey !~ 'L0071131000') OR (rastitelnos_line.objectkey !~ 'L0071131100') OR (rastitelnos_line.objectkey !~ 'L0071224000') OR (rastitelnos_line.objectkey IS NULL);
ALTER TABLE rastitelnos_line_10000
OWNER TO alimuradov;
GRANT ALL ON TABLE rastitelnos_line_10000 TO alimuradov;
WHERE (rastitelnos_line.objectkey !~ 'L0071131000') OR (rastitelnos_line.objectkey !~ 'L0071131100') OR (rastitelnos_line.objectkey !~ 'L0071224000') OR (rastitelnos_line.objectkey IS NULL);
WHERE rastitelnos_line.objectkey !~ 'L0071224000' OR rastitelnos_line.objectkey IS NULL;
Answer the question
In order to leave comments, you need to log in
yes, curious behavior...
try doing this
CREATE OR REPLACE VIEW rastitelnos_line_10000 AS
SELECT *
FROM rastitelnos_line
WHERE rastitelnos_line.objectkey NOT IN ('L0071131000','L0071131100','L0071224000') OR rastitelnos_line.objectkey IS NULL;
I created a condition with the query that you wrote, now no record is displayed in the view, moreover, when viewing the view from pgadmin, the condition filter has a strange look
WHERE (rastitelnos_line.objectkey::text <> ALL (ARRAY['L0071131000'::character varying, 'L0071131100'::character varying, 'L0071224000'::character varying]::text[])) OR rastitelnos_line.objectkey IS NULL;
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question