MYSQL將一張表的數(shù)據(jù)更新到另外一張表中
方式一:
update 更新表 set 字段 = (select 原始數(shù)據(jù) from 原始表 where 更新表.id = 原始表.id)
例如:
update a set code = (select b.code from b where a.id = b.id),
name = (select b.name from b where a.id = b.id)
方式二:
update 更新表,原始表 set 更新表數(shù)據(jù) = 原始表數(shù)據(jù) where 更新表.id = 原始表.id文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-778731.html
例如:update a,b set a.code = b.code ,a.name = b.name where a.id = b.id;文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-778731.html
到了這里,關(guān)于MYSQL將一張表的數(shù)據(jù)更新到另外一張表中的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!