This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2019-12-29
Channels
- # announcements (7)
- # babashka (36)
- # beginners (67)
- # braveandtrue (11)
- # cider (8)
- # clojure (52)
- # clojure-conj (4)
- # clojure-poland (1)
- # clojure-spec (9)
- # clojure-uk (8)
- # clojurescript (42)
- # core-typed (11)
- # cursive (4)
- # emacs (1)
- # fulcro (1)
- # graalvm (24)
- # hoplon (10)
- # hyperfiddle (1)
- # off-topic (30)
- # re-frame (7)
- # reitit (1)
- # sql (1)
Not exactly Clojure-specific, hope that's alright :-)
I have a table b
that's effectively an exclusion filter for another table a
, so it's storing the primary key of rows that I want to exclude. Upon selection from a
, I want to update b
with the primary key from the retrieved rows, but I also want to return the rows from a
.
With Postgres I can do something like
INSERT INTO b
SELECT id FROM a LEFT JOIN b ON a.id=b.id WHERE b.id IS NULL
RETURNING *
But then if I want to select anything else than id
from a
, it won't work.
Is there (with Postgres) a way of selecting multiple columns from a
and updating b
with only id
in one statement?
Edit: This looks promising:
https://dba.stackexchange.com/a/90215/111942
Something like
WITH ins(id) AS ( [stmt above ] ) SELECT ins.id, ... FROM ins JOIN a on a.id=ins.id