How to Conditionally Update Multiple Database Rows

I anyone has time, I need a little education on handling a database issue as I’m new to this.

I have a database of customers used by a plugin and in that table is a field “wp_user_id” which is NULL for some entries. I need to update all rows with NULL to be replaced with the real user id. All of those entries already have an email address and that email address field corresponds to their WP user. All the data in the table has already been escaped.

I am trying to create an include to update that database every time that plugin’s module is opened. So I need to fetch all rows with wp_user_id = NULL, then fetch the correct user id using get_user_by and then update that row.

I have read many examples of routines for different kinds of updating, but I am not sure how to proceed because I am new. Should I be trying to fetch many rows into an array, or should I be running some kind of loop that runs through every row in the database?