mysql update 字段select 内容

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/jmlxx/article/details/84673188
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

猜你喜欢

转载自blog.csdn.net/jmlxx/article/details/84673188