Reputation: 107
I have two tables, mileage_registrants and date_import. Both tables have field 'user_id' and 'department'. What I want to do is to update department of mileage_registrants with department info from table data_import by matching the user_id of both tables.
The query I got is wrong. How to write the correct query? thanks
Update mileage_registrants
SET mileage_registrants.department = test_date_import.department
INNER JOIN test_date_import
ON(test_date_import.user_id = mileage_registrants.user_id)
Upvotes: 0
Views: 88
Reputation: 125708
This works in SQL Server, and should work in MySQL:
UPDATE
mileage_registrants
SET
m.department = t.department
FROM
mileage_registrants m
INNER JOIN
test_date_import t
ON
t.user_id = m.user_id
Upvotes: 1