Skip to content
Advertisement

Update user id by looking up two other tables

I have a table/sql issue I don’t know how to solve.

I need to update/create a table of user ids with order ids.

Therefore I have to get a new user_id, by searching for the email in an old list. With the email adress I need to look up the new user id.

So the logic is like: order_id -> look at the old user_id -> look at the email -> look at the new user_id

I tried to create an example:

I have no idea how to do that action. I don’t even know what to search for.

What I managed to do is a LEFT JOIN sql statement to compare the user ids and create a list of matching user_ids. But I have no idea how to look up over even more tables…

Hopefully someone can help me. If it’s easier I could also try to do it in spreadsheets.

Thanks in advance!

Advertisement

Answer

Assuming you just want to return the query then use;

However, if you want to write the result into a new table, then you need to create the table first.

See Demo

User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement