简体   繁体   English

Microsoft Access更新查询

[英]Microsoft Access Update Query

I am trying to make a insurance company database. 我试图建立一个保险公司数据库。 I have a customer table where there is a field for their payment date, and also another field called PaymentTypeID which is linked to a PaymentType table. 我有一个customer表,其中有一个用于其付款日期的字段,还有另一个称为PaymentTypeID的字段,该字段链接到PaymentType表。 The ID is either 1 or 2 based on whether they pay monthly or annually. ID是1还是2,具体取决于他们是按月支付还是按年支付。 I have another table which is for policies where there is an effective date, the date of when their policy is expiring, so it should either expire in a month or a year. 我有另一个表,该表用于政策的生效日期,即政策到期的日期,因此它应该在一个月或一年后到期。

What I want is a query to update the effective date from the payment date in the policy table based on whether their paymenttypeID is 1 or 2. 我想要的是一个查询,根据其付款类型ID是1还是2,从策略表中的付款日期开始更新生效日期。

I would rather this be done in Design view rather than sql view 我宁愿在设计视图而不是sql视图中完成此操作

Thanks 谢谢

You can use an IIf expression to set the value depending on the paymenttypeID. 您可以使用IIf表达式来根据PaymentTypeID设置值。 In the "Update To" row, use 在“更新到”行中,使用

= IIf(paymenttypeID = 1, valueToInsertIfPayedMonthly, valueToInsertIfPayedYearly)

Obviously, valueToInsertIfPayedMonthly and ...Yearly need to be replaced by the actual values that you want to set. 显然, valueToInsertIfPayedMonthly...Yearly需要替换为您要设置的实际值。

If you have more than two values, use the Choose function instead of IIf . 如果您有两个以上的值,请使用Choose函数而不是IIf

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM