How exactly do I get this to work? I am trying my best to form a query that takes the primary keys generated from the first query and then inserts them into the 2nd table along with a static 2nd value(33). I am obviously getting a "more than one row returned by a subquery used as an expression" error. I'm googled my eye balls out and can't figure out this issue. Maybe there's a better way to do what I am trying to do.
I am using Postgresql 9.5 if that matters.
WITH x AS (INSERT INTO OPTIONS (manufacturer_id, category, name, description)
VALUES (
UNNEST(ARRAY['10', '22', '33']),
'ExtColor',
UNNEST(ARRAY['EC', 'IC', 'IO']),
UNNEST(ARRAY['a', 'b', 'c'])
)
RETURNING option_id)
INSERT INTO opt_car_data (car_id, option_id) VALUES ((SELECT option_id FROM x), 33);