CREATE VIEW view_circuit_with_status AS (SELECT r.*,s.circuit_status,s.customer_id AS s_customer_id,p.line_speed,p.customer_id AS p_customer_idFROM view_circuit rJOIN view_circuit_product_main s ON r.circuit_id = s.circuit_idAND r.customer_id IS NOT DISTINCT FROM s.customer_idJOIN view_circuit_product pON r.circuit_id = p.circuit_idAND r.customer_id IS NOT DISTINCT FROM s.customer_id);
SELECT * FROM view_circuit_with_status WHERE customer_id = 1;
A couple of random thoughts:
1.
TABLE circuit (circuit_id)
TABLE customer (customer_id)
TABLE circuit_customer (circuit_id, customer_id)
2.
INSERT INTO customer (0, 'Customer number standing in for customer not assigned');
While IS DISTINCT FROM could very well use some more love I surmise the reason it hasn't gotten it is because most data model set things up so that it never needs to be used.
David J.