UPDATE hm_opportunities
INNER JOIN (
SELECT
id,
SUBSTRING_INDEX(opportunity_city, '-', 1) AS province
FROM
hm_opportunities
) b ON hm_opportunities.id = b.id
SET hm_opportunities.province = b.province;
UPDATE hm_opportunities
INNER JOIN (
SELECT
id,
SUBSTRING_INDEX(opportunity_city, '-', -1) AS city
FROM
hm_opportunities
) b ON hm_opportunities.id = b.id
SET hm_opportunities.city = b.city;
- 更新某个字段,根据查找的字段值
- update tb inner join (select) on contidions set field=value