Update table based on a list on another table (1 Viewer)

Mackbear

Registered User.
Local time
Today, 10:06
Joined
Apr 2, 2019
Messages
168
Hello all, good day! I apologize if I am opening up a lot of thread lately, just can't figure out how to do stuff...I really appreciate your help everyone!

So I have a list of let's say approved companies. I would like to update a field on a table based on this list. I have a company name field on that table and an approved field. I would like to update the approve field to have a value "Yes" if the company name on the table is on the list. How do I do it?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:06
Joined
Oct 29, 2018
Messages
21,480
Hi. You would use an UPDATE query. You can join the two tables in your query and update the approved field.
 

Mackbear

Registered User.
Local time
Today, 10:06
Joined
Apr 2, 2019
Messages
168
Yes, update query but how do I make it reference the other table? I'm sorry I can't seem to construct it... I am up until
UPDATE tbl_info WHERE...

And I don't know how to proceed from there... because the WHERE only looks for one value, do I add a dllookup on it? Having difficulty constructing it.:confused:
 

theDBguy

I’m here to help
Staff member
Local time
Today, 08:06
Joined
Oct 29, 2018
Messages
21,480
Yes, update query but how do I make it reference the other table? I'm sorry I can't seem to construct it... I am up until
UPDATE tbl_info WHERE...

And I don't know how to proceed from there... because the WHERE only looks for one value, do I add a dllookup on it? Having difficulty constructing it.:confused:
Hi. Yes, you can do it using a WHERE clause, but I was saying it's easier/simpler just to JOIN the two tables. For example:
Code:
UPDATE Table1 INNER JOIN Table2 ON Table1.CompanyName=Table2.CompanyName SET Table1.Approved=True
Hope it helps...
 

Mackbear

Registered User.
Local time
Today, 10:06
Joined
Apr 2, 2019
Messages
168
Hi. Yes, you can do it using a WHERE clause, but I was saying it's easier/simpler just to JOIN the two tables. For example:
Code:
UPDATE Table1 INNER JOIN Table2 ON Table1.CompanyName=Table2.CompanyName SET Table1.Approved=True
Hope it helps...

Thanks for thissss this is exactly what I need! :D:D:D
 

Users who are viewing this thread

Top Bottom