从第二个 table 更新查询 mysql
update query maysql from second table
我有 2 个 table,需要更新第一个 table 的一列
我试过这个
update user_details as ud set ud.corporationName =
select cop.corporationName FROM corporation as cop where cop.id = ud.corporation_id
帮我解决一下。
谢谢
您可以使用基于内部联接的更新
update user_details ud
INNER JOIN corporation cop ON cop.id = ud.corporation_id
set ud.corporationName = cop.corporationName
我有 2 个 table,需要更新第一个 table 的一列
我试过这个
update user_details as ud set ud.corporationName =
select cop.corporationName FROM corporation as cop where cop.id = ud.corporation_id
帮我解决一下。 谢谢
您可以使用基于内部联接的更新
update user_details ud
INNER JOIN corporation cop ON cop.id = ud.corporation_id
set ud.corporationName = cop.corporationName