How can I reference an ID via name during INSERT?

32 Views Asked by At

What I want to do is basically

WITH c AS (
  SELECT id FROM chapter WHERE name='Chapter 1.00'
)
INSERT INTO world (name, since, wiki_link) VALUES
  ('Innworld', FIRST_VALUE(c.id), 'https://wiki.wanderinginn.com/Innworld');

However, that doesn't work:

Error occurred during SQL query execution

Reason:
SQL Error [42P01]: ERROR: missing FROM-clause entry for table "c"

How can I make it work?

0

There are 0 best solutions below