这是与MS Access相关的帖子。
如何将INSERT INTO语句更改为UPDATE语句?
DoCmd.RunSQL "INSERT INTO A_tblStagingTablesChecksHEADERS (Header, Header2) " _
& "SELECT DISTINCT(SELECT F1 FROM tblStagingIssuerNames_ReverseRepos " _
& "WHERE F1 = 'ISSUER CODE') as F1data, " _
& "(SELECT F51 FROM tblStagingIssuerNames_ReverseRepos " _
& "WHERE F51 = 'INSTRUMENT REFERENCE (BOE)') as F2data " _
& "FROM tblStagingIssuerNames_ReverseRepos;"
我尝试过以下(不成功):
DoCmd.RunSQL "UPDATE A_tblStagingTablesChecksHEADERS, tblStagingIssuerNames_ReverseRepos " _
& "SELECT DISTINCT(SELECT F1 FROM tblStagingIssuerNames_ReverseRepos " _
& "WHERE F1 = 'ISSUER CODE') as F1data, " _
& "SELECT DISTINCT(SELECT F51 FROM tblStagingIssuerNames_ReverseRepos " _
& "WHERE F51 = 'INSTRUMENT REFERENCE (BOE)') as F2data " _
& "FROM tblStagingIssuerNames_ReverseRepos," _
& "SET A_tblStagingTablesChecksHEADERS.Header = F1data, " _
& "SET A_tblStagingTablesChecksHEADERS.Header2 = F2data;"
对于这两个语句(有和没有别名),我得到运行时错误'3075':
查询表达式中的语法错误'(SELECT DISTINCT(SELECT F1 FROM tblStagingIssuerNames_ReverseRepos WHERE F1 ='ISSUER CODE'))'。
答案 0 :(得分:0)
您使用的是无效的Update语句语法。试试这个:
DoCmd.RunSQL "UPDATE A_tblStagingTablesChecksHEADERS " _
& "SET Header = (SELECT DISTINCT F1 FROM tblStagingIssuerNames_ReverseRepos " _
& "WHERE F1 = 'ISSUER CODE'), " _
& "Header2 = (SELECT DISTINCT F51 FROM tblStagingIssuerNames_ReverseRepos " _
& "WHERE F51 = 'INSTRUMENT REFERENCE (BOE)')";