I've got 3 tables. Companies, Kommuner and Fylker.
The companies table have an empty field forretningsadresse_fylke but an other field forretningsadresse_kommune with a value. 
So basically, I need to fill in forretningsadresse_fylke, based on the value of forretningsadresse_kommune.
Now, the value of forretningsadresse_kommune and the value I want for forretningsadresse_fylke is stored in the Kommuner and Fylker tables.
So I wrote this query, but that doesn't seem to work because after 600 seconds the "MySQL server goes away".
UPDATE companies, fylker, kommuner
SET companies.forretningsadresse_fylke = (
    SELECT fylkeNavn 
    FROM fylker 
    WHERE fylker.fylkeID = kommuner.fylkeID
)
WHERE companies.forretningsadresse_kommune = kommuner.kommuneNavn
Here is what the Kommuner and Fylker tables look like.
Kommuner Table
Fylker Table
companies Table
            | forretningsadresse_fylke  | forretningsadresse_kommune |
            |===========================|============================|
            |                           |                            |
            |                           |                            |
            |                           |                            |
            |                           |                            |
            |                           |                            |
            |                           |                            |
So I was wondering if there was something wrong with the query? Also, it might be good to mention, the table I try to update (Companies) has over 1 million rows.
Thanks in advance!



 
     
     
     
     
    