将mysql中的一张表中的一个字段数据根据条件导入另一张表中

添加字段:alter table matInformation add facid varchar(99)  default '';

导入数据:update matInformation m set facid=(select facid from material_register v where m.partNumber=v.partNumber);(参考:https://blog.csdn.net/mar_fuck/article/details/79460571)

遇到问题:ERROR 1366 (HY000): Incorrect string value: '\xCE\xA9,1%,...' for column 'facid' at row 2(参考:https://blog.csdn.net/xiatiancc/article/details/88013915)

  解决:show create table material_register;

    show create table matInformation;

    两张表的字符集不一致,需要修改要导入数据的那一张表.

    alter table matInformation convert to character set utf8mb4 collate utf8mb4_bin;

猜你喜欢

转载自www.cnblogs.com/thoughtful-actors/p/10645968.html