我正在尝试将记录插入到另一个表中未列出的表中,并且在字段中也有一定的值。我提出的工作原因,但由于某种原因,它只返回那些在APPROVAL STATE字段中具有APPROVED或APPROVED WITH CHANGES值的那些,我对如何修复它感到非常困惑。对此问题的任何帮助将不胜感激!
verifiedForm = "INSERT INTO VerifiedFormularies ([CLIENT ID], [CLIENT NAME], [MARKET SEGMENT], [FORMULARY ID], [FORMULARY NAME], [FORMULARY VERSION], [APPROVAL STATE]) " & _
"SELECT DISTINCT DD.[CLIENT ID], DD.[CLIENT NAME], DD.[MARKET SEGMENT], DD.[FORMULARY ID], DD.[FORMULARY NAME], DD.[FORMULARY VERSION], DD.[APPROVAL STATE] " & _
"FROM " & tableName & " as DD " & _
"Where DD.[Client ID] NOT IN (SELECT Exclusions.[Client ID] FROM Exclusions) " & _
"AND DD.[APPROVAL STATE] IN (""APPROVED AND PUBLISHED"",""APPROVED"",""APPROVED WITH POSTED CHANGES"",""APPROVED WITH CHANGES"") "
答案 0 :(得分:0)
也许这......替换了“with”。我认为你这样做虽然VBA并且我不确定驱动程序如何处理“vs”即使这是使用ADO ...也许是驱动程序doens不正确地对待“”但是我希望“批准有变化”也会失败......
但我倾向于数据问题或您的预期结果不正确。
verifiedForm = "INSERT INTO VerifiedFormularies ([CLIENT ID], [CLIENT NAME], [MARKET SEGMENT], [FORMULARY ID], [FORMULARY NAME], [FORMULARY VERSION], [APPROVAL STATE]) " & _
"SELECT DISTINCT DD.[CLIENT ID], DD.[CLIENT NAME], DD.[MARKET SEGMENT], DD.[FORMULARY ID], DD.[FORMULARY NAME], DD.[FORMULARY VERSION], DD.[APPROVAL STATE] " & _
"FROM " & tableName & " as DD " & _
"Where DD.[Client ID] NOT IN (SELECT Exclusions.[Client ID] FROM Exclusions) " & _
"AND DD.[APPROVAL STATE] IN ('APPROVED AND PUBLISHED','APPROVED','APPROVED WITH POSTED CHANGES','APPROVED WITH CHANGES') "
我不确定访问如何处理“vs”虽然....
Select count(*), [approval state] from tablename group by [approval state]
返回什么?
如果0指望两个丢失,那么数据问题。
然后是什么......
SELECT *
FROM tablename DD
LEFT JOIN exclusions E
on DD.[Client ID] = E.[Client ID]
WHERE DD.[Approval State] in (""APPROVED AND PUBLISHED"",""APPROVED WITH POSTED CHANGES"")
如果没有记录,则没有客户DD记录,其中批准状态不在排除列表中。