Getting auto-increment value from DB after save

Hi all,
Some background:
I have a table on mysql db, with an auto-increment ID field.
The scenario is as following:

  1. Save data to a mySQL table
  2. Retrieve the assigned ID field value (as mentioned it's auto increment, so the DB is assigning the value to the ID field)
  3. Use the ID value in a REST API call
  4. Update the above record with a returned value from the API

I'm having difficulties in getting the value assigned to the ID field, would appreciate your help in pointing me out to the right direction

Best
Sharon

At least in SQL Server and Postgres (I don't have experience using MySQL with Retool), Retool returns the entire inserted row after an insert.

So in practice, after you run your insert query, go look at the query's data property. The entire inserted row should be there, including your IDs.

1 Like

Thanks @bradlymathews this actually worked for me!
I was able to access the data via query1.data.result[0]

1 Like