--先根据 模版类型编码 查询单据模版中 对应主模版和子模版的pk值 select * from pub_billtemplet where pk_billtypecode='模版类型编码'; --先查询主表对应的信息之后把主表的PK值改成子表的PK值更新上去 select * from pub_billtemplet_t where pk_billtemplet='对应主模版单据主键' and tabcode='表编码值'; select * from pub_billtemplet_b where pk_billtemplet='对应主模版单据主键' and table_code='表编码值' update pub_billtemplet_t set pk_billtemplet='对应主模版单据子键' where pk_billtemplet='对应主模版单据主键' and tabcode='表编码值'; update pub_billtemplet_b set pk_billtemplet='对应主模版单据子键' where pk_billtemplet='对应主模版单据主键' and table_code='表编码值'