I have an INSERT
statement like so that returns the inserted IDs:
INSERT INTO encyclopedias (page_id)
SELECT page.id FROM pages
RETURNING id;
INSERT INTO cookbooks (page_id)
SELECT page.id FROM pages
RETURNING id;
Which returns something like:
id
----
1
2
id
----
3
4
When parsing the output, I'd like tell which table the IDs are from, like either:
encyclopedia id
----
1
2
cookbook id
----
3
4
or:
table, id
----
encyclopedias, 1
encyclopedias, 2
table, id
----
cookbooks, 3
cookbooks, 4
How would I do that?