For the purpose of this guide, it's presumed that you've already established a successful connection to your data source. We'll use PostgreSQL for this example, but you can adjust the queries based on the SQL database that you are using.
<imgstyle={{border:'0',marginBottom:'15px'}}className="screenshot-full"src="/img/how-to/bulk-update-multiple/new/populate.png"alt="Display Data on the Table"/>
- Create a new Run Javascript query and use the code below to generate the SQL query for updating multiple rows. The query will be named as *runjs1* by default.
return `UPDATE users SET ${cols.join(", ")} WHERE id = '${id}';`;
});
return sql
```
Here the unique identifier is **id** and Table component's name is **table1**. You can update the unique identifier if you are using a different column as a unique identifier. You can also update the Table name if you have renamed it, the default name is *table1*.
<imgstyle={{border:'0',marginBottom:'15px'}}className="screenshot-full"src="/img/how-to/bulk-update-multiple/new/runjs1.png"alt="RunJS code to later the data"/>
## 7. Adding Event Handlers to Execute Queries in Sequence
- Edit the Table component and add an event handler for `Save Changes` event so that whenever a user will edit the Table and hit the Save Changes button the *runjs1* query will run.
- Optionally, add loading state to the Table by clicking on `fx` next to the `Loading state` property.
- Use the below code to show the loading state whenever a query is getting executed.
- Now, go to the *runjs1* query and add an event to run the *update* query for Query Success event. This will run the *update* query after the *runjs1* query is successfully executed.