How are multiple WordPress WPDB queries handled?

Method 1 – Check for the last row id.

SELECT * FROM $incentives_table WHERE user_id = %s AND credited = FALSE

You can get the last row in the array and get the column row_id.

And then you can update with the where

WHERE user_id = %s AND credited = FALSE AND row_id <= {last row id}

Method 2 – temp column.

First you need to create another column in the table for this lets call it for example ‘temp_user_update`.

Now when you want to get the data and then update you need first to create variable to use in your code and save it in this column.

$temp_user_update = $sponser->ID.time();

UPDATE table set temp_user_update="{$temp_user_update}" WHERE user_id = %s AND credited = FALSE

After this step you can select and update with the WHERE temp_user_update="{$temp_user_update}"