I am trying to load information from different tables into one. I have the following code:
UPDATE coche ch
INNER JOIN modelo mo ON mo.id = ch.codmodelo
INNER JOIN color co ON co.idmodelo = ch.codmodelo
INNER JOIN matricula ma ON ma.idmodelo = ch.codmodelo
SET ch.codmodelo = mo.id, ch.codcolor=co.id, ch.codmatricula=ma.id
WHERE mo.id >0
My intention is to update the fields of the cars table, with a specific field from the model, color and license plate tables.
If someone can help me to understand how to do it. What I have found on the internet or asked has not helped me to solve it. Thanks in advance
To simulate
JOIN
in aUPDATE
you must useFROM
, I recommend the official documentationfor instance:
and in your case it would be something like this: