Chris Wilson
Chris Wilson

Reputation: 203

MySQL Update with a join

I've looked around and can't find exactly what I am looking for... I have two tables:

equipmentinventory - contains IDs, locations, and descriptions of all kinds of equipment, computers included. (the field I am concerned with here is the ID and

software - contains a list of software on each computer.

I am just starting out and want to default populate the entire list of computers in the equipmentinventory with software, let's start with "Windows 7, Pro"

I'm very weak in constructing SQL statements (by the way, this is the latest version of MySQL I am talking about). What I want to do is use an update query to update all computers:

update software
set software.name="Windows 7"
where equipmentinventory.item="computer" Joined on ID ???????

Thanks!

Upvotes: 0

Views: 40

Answers (1)

clancer
clancer

Reputation: 613

I believe this is answered here How can I do an UPDATE statement with JOIN in SQL?

But to give you specific advice on your problem try

update software s  
inner join equimentinventory ei on  
    s.id = ei.id  
set s.name = "windows 7"  
where ei.item="computer"  

Upvotes: 2

Related Questions