How do I use `WHERE NOT EXISTS`?

I am trying to write the followng where condition:
INSERT INTO Filing (location_id, filing_date, other_columns)
SELECT L.location_id, '2023-01-01'::date, default_values_for_other_columns
FROM Location L
WHERE NOT EXISTS (
SELECT 1
FROM Filing F
WHERE F.location_id = L.location_id
AND F.filing_date = '2023-01-01'::date
);
INSERT INTO Filing (location_id, filing_date, other_columns)
SELECT L.location_id, '2023-01-01'::date, default_values_for_other_columns
FROM Location L
WHERE NOT EXISTS (
SELECT 1
FROM Filing F
WHERE F.location_id = L.location_id
AND F.filing_date = '2023-01-01'::date
);
But Im not sure how to approach it.
Solution:
Message Not Public
Sign In & Join Server To View
Jump to solution
2 Replies
Solution
Unknown User
Unknown User10mo ago
Message Not Public
Sign In & Join Server To View
bombillazo
bombillazoOP10mo ago
thanks!
Want results from more Discord servers?
Add your server