我有两个领域。一个是customerid,另一个是custidref。custidref是customerid字段的最后6位数字。我做了一次搜索,发现了一个类似的问题,结果发现:
Update mysql partial based on another field
虽然这个问题和我的问题一样,但我必须使用另一种方法来获取我的子字符串。我在用一本用Python写的词典。不幸的是,我不能使用常规的更新查询,因为字典是基于其他人编写的库代码的。我的代码是:
for valuedict in valuedictlist:
fieldupdate=customertypedict['fieldupdate']
newaccount=valuedict['newaccount']
fieldref=customertypedict['fieldref']
if customertypedict['table']=='customer' and customertypedict['product']=='insurance':
customerobj.custidref=customerobj.customerid[-6:]
customerobj.fieldref=fieldref
customerobj.Change({'changedict':{fieldupdate:newaccount,fieldref:customerobj.custidref}})
我想知道--我是否根据customerid字段的更改正确更新custidref字段?我所要做的是custidref是一个落后的更新。它不具有当前customerid的6位数字,而是具有上一个customerid的数字。你知道吗
我能解决这个问题。我把代码改成:
这抓住了6位数字作为必要的,我能够消除一行代码。你知道吗
相关问题 更多 >
编程相关推荐