本文介绍了查询根据条件更新列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 我每天都会收到以下格式的文件: - CID Mobile FirstName Lastname UpdateIdentifier 第一次文件将以这种方式包含记录: - CID Mobile FirstName Lastname UpdateIdentifier 1 999999 ABC PQR N 此记录将插入两个主表中,例如TableA和表B. 下次再来一个文件。但这次数据如下: - CID Mobile FirstName Lastname UpdateIdentifier 1 999999 ABCD PQR U 这次记录将在表格和表格b中更新(即,firstname将从abc更改为abcd,更新itentifier将从N到U) 一旦UpdateIdentifier首次从N更改为U,我们必须在其中插入一个值为10的列。 必需输出如下: - CID Mobile FirstName姓氏UpdateIdentifier积分 1 999999 ABCD PQR U 10 下次每当Updateitenfier更改为U时,我们应该允许其他列数据更新但是points列应该没有改变,因为我们只需要在第一次更改为U时需要多点。 请帮助。 我尝试了什么: 我正在考虑采用标志变量在这两个表中以及第一次当updateitenfier是U increement时它是1. 下次每当数据到来时检查标志值。如果它是一个不发布点。 请帮助代码。解决方案 Everyday I will receive file in the below format:-CIDMobileFirstNameLastnameUpdateIdentifierFirst time the file will contain record in this fashion:-CIDMobileFirstNameLastnameUpdateIdentifier1999999ABC PQR NThis record will be inserted in two main tables say TableA and table B.Next time another file will come. But this time the data will be like below:-CIDMobile FirstNameLastnameUpdateIdentifier1999999 ABCD PQR UThis time the record will be updated in tablea and table b.(i.e. firstname will change from abc to abcd and update itentifier will change from N to U)Once the UpdateIdentifier has got changed from N to U for the first time we have to insert a column Points with value as 10 in it.Required Output will be below:-CIDMobileFirstNameLastnameUpdateIdentifierPoints1999999ABCD PQR U 10Next time whenever the Updateitenfier is changed to U we should allow the other columns data to be updated but the points column should not get changed since we need to alot points only at first time when it changes to U.Please Help.What I have tried:I am thinking of taking a flag variable in both the tables and at first time when the updateitenfier is U increement it to 1.next time whenever the data is coming check the flag value. if it is one do not post point.Please help with the code. 解决方案 这篇关于查询根据条件更新列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云!
08-23 00:48
查看更多