Retool DB - adding lookup fields from a linked record from a different table

Hi everyone, :wave:
First question in this cool community!
How can one the has a table containing a foreign key add a column containing a value from that foreign key's record?

If I would use the "Airtable language": adding a "lookup" field of a "linked record"?

Thanks a lot!

@Roy1506 Welcome to the forum!
Can you share more information? Screenshots, field names, code, etc.?

Thanks @ScottR,
I want to get the "name and "folderId" from the "scenarios" table to the "logs" table according to the "scenarioId" that is the foreign key (which is the primary key "id" in "scenarios" table).

P.S. I heard and experienced that using camelCase naming convention isn't recommend for Postgres but too late to go back now :sweat_smile:

The two fields folderId and name must already be existing columns in the logs table for you to insert them into the logs table. YOu can then use a with clause statement:

WITH selected_scenarios AS (
  SELECT name, folderId
  FROM scenarios
INSERT INTO logs (name, folderId)
SELECT name, folderId
FROM selected_scenarios;
1 Like

Cool @ScottR,
How should I set-up the field?

That looks right just make sure that both columns created in the logs table match the same POSTGRES type as in the scenarios table