Creating a related record in form help

Hi,
I am new to retool. I have a sql data source. I have a projects table with foreign key address id (that is optional) and an address table. It is a one to one relationship. I managed in retool to make a new form component in the existing form and load the information from the address table when an address id exists. However, I can't figure out, how to prepare a write query in retool and relate that record to the project being browsed. My address ID field on the address table is an auto increment identity (so it is generated automatically)

TLDR how to make it so when I create a new row in my address table it automatically takes the new address id and adds it to the appropriate row in the project table ?

-At the same time when performing a query to load date in a retool table, retool combines the keys used in the join condition into an array.Is it possible to avoid that behaviour ?

Thanks

@Sammy_b Welcome to the forum!
When you say in TLDR: ...project table and address table in the database or in Retool IDE?
Can you share some screenshots?

Hi there! I agree screenshots could be helpful if you're able to share :slightly_smiling_face:

TLDR how to make it so when I create a new row in my address table it automatically takes the new address id and adds it to the appropriate row in the project table ?

It sounds like you may need to write multiple queries and chain them together on success. Your first insert or update query may return some helpful data about the recently inserted record in the .data property that you can reference in subsequent queries

-At the same time when performing a query to load date in a retool table, retool combines the keys used in the join condition into an array.Is it possible to avoid that behaviour ?

I'm not quite sure I'm following this question yet. Are you looking to remove certain properties from an array? If so, you may be able to use lodash's pick - like this example