我试图在SQL中插入一个表但由于某种原因它说查询值和目标字段的数量不一样,我不知道为什么会这样说。我已经研究了错误(3346),没有运气修复。我对VBA很新,所以任何帮助都会非常感激。
"INSERT INTO Clients (Col1, Col2, Col3)" & _
"SELECT DISTINCT DD.[Client ID] " & _
"FROM " & tableName & " as DD " & _
"Where CL.[Client ID] NOT IN (SELECT DD.[Client ID] FROM " & tableName & " as DD)"
答案 0 :(得分:2)
您正试图从一列中插入3列,这让他感到困惑 这将有效:
"INSERT INTO Clients (Col1)" & _
"SELECT DISTINCT DD.[Client ID] " & _
"FROM " & tableName & " as DD " & _
"Where DD.[Client ID] NOT IN (SELECT DD.[Client ID] FROM " & tableName & " as DD)"
但它没有插入任何行,因为select语句没有结果。 多想一想,确切地确定要在哪里插入?