简体   繁体   English

MS Access中的SQL更新语句

[英]SQL Update Statement in MS Access

Trying to get this query to work in MS Access. 试图使该查询在MS Access中工作。

Update Network.Location=Enclave.Location Where Enclave.Site=No AND 
Network.AlternateLocation=Enclave.Location Where Enclave.Site=Yes

I'm not sure how to get this to do exactly what I want which is store Enclave location in network location if the enclave site field is No and if yes store encalve location in alternate location, meaning it would store a blank value in network location in that row. 我不确定如何正确地执行此操作,如果安全区站点字段为“否”且如果是,则将安全区位置存储在网络位置中,如果是,则将安全区位置存储在备用位置中,这意味着它将在网络位置中存储空白值在那一行。

Key fields update : 关键字段更新

Update Network InnerJoin Enclave On Network.ID=Enclave.ID Set 
Network.Location=Enclave.Location Where Enclave.Site=No AND 
Network.AlternateLocation=Enclave.Location Where Enclave.Site=Yes

You should break the command in two: 您应该将命令分为两部分:

Update Network SET Location=Enclave.Location Where Enclave.Site=No;
Update Network SET AlternateLocation=Enclave.Location Where Enclave.Site=Yes;
UPDATE Network Inner Join Enclave ON Network.ID=Enclave.ID
SET Network.Location = IIF(Enclave.Site=False, Enclave.Location, ""),
Network.AlternateLocation = IIF(Enclave.Site=True, Enclave.Location, "")

Note: I haven't tried this & guess, this should work. 注意:我还没有尝试过这个&猜猜,这应该可行。
Also, I have assumed that you will want the field to be updated with blank, if it doesn't satisfy the condition. 另外,我假设如果不满足该条件,则希望将字段更新为空白。

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

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