How To Get The Last Record From MySQL Database Using Power Automate

Overview

Sometimes we have a situation, where we have some off-beat data source like MySQL. If we want to insert data to the MySQL database, we need the last submitted Auto Incremented ID. In this blog, we will try to understand how we can get the Last Record from MySQL using Power Automate and increment the record by one.

Step 1

Add an action > Get Rows

Add table name.

In Order By – set “id desc” (Your Auto incremented / Primary Key Column Name)

Maximum Get Count = 1

Step 2

Initialize the Variable and Set the Variable value!

It will automatically add Apply to Each when you try to write the following formula.

add(items('Apply_to_each')?['id'],1)

Step 3

Add an Action Insert row and set different fields. In id column pass the variable defined in step 2.

Conclusion

This is how we can easily get the last record from MySQL Database using Power Automate. Isn’t that cool?