Answer the question
In order to leave comments, you need to log in
What query to write to transfer data from one table to another with the condition of matching keys?
There are 2 tables. In one and in the second there is a glav_id field, they coincide with each other.
I need to transfer the values of the region field from Table 2 to Table 1 in the region field in accordance with the glav_id field. You need to create a SQL query.
Something like this: UPDATE `tabl_1` SET `region`= (SELECT `region` FROM `tabl_2` WHERE `tabl_1`(`glav_id`) = `tabl_2`(`glav_id`)) but this is not a valid query
Please help! Thanks in advance!
Answer the question
In order to leave comments, you need to log in
UPDATE
`tabl_1`
INNER JOIN
`tabl_2`
ON
`tabl_2`.`glav_id` = `tabl_1`.`glav_id`
SET
`tabl_1`.`region` = `tabl_2`.`region`
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question