I'd like to do something like this:
INSERT INTO table2(name)
INSERT INTO table1(name, address) VALUES ('me', 'home')
RETURNING name;
And then I would expect a new record in table2 with 'me'
in name
. This would work fine with a SELECT
returning the values, but I'm having trouble with the nested insert.
Best Answer
Use a data modifying CTE: