I have a complex query that join multiple tables and return many member ids (line 5)
For each memberId I want to insert a memberSegment record, consisting of the memberId (new for each insert) and a segmentId (always the same/not list)
INSERT INTO db."memberSegment"(
"memberId",
"segmentId")
VALUES (
(select table."memberId" complex query returns many ids ),
(SELECT id FROM db.segment where "idName" = 'due-for-360')
);
From reading on SO this is how I interpret it should look, but I am getting following error message, making me think that my query is not expecting a list in either values.
ERROR: more than one row returned by a subquery used as an expression SQL state: 21000
Each query on its' own returns following: