我在 MS ACCESS 数据库中遇到错误“查询值和目标字段的数量不相同”
这是我的查询:
我将此命名为 QryMetrics
SELECT A, B, C, D, E, F
FROM (SELECT count(ID ) as A FROM RelevantResults WHERE Field1 Is Not Null and Field1 <> Chr(13) & Chr(10)) AS Q1,
(SELECT count(ID) as B FROM RelevantResults WHERE Field2 Is Not Null) AS Q2,
(SELECT COUNT(ID) as C FROM RelevantResults WHERE Field3 Like '*.jpg' AND Field1 Is Not Null) AS Q3,
(SELECT COUNT(ID) as D FROM RelevantResults WHERE Field3 Like '*.jpg' OR Field1 Is Not Null) AS Q4,
(SELECT COUNT(ID) as E FROM RelevantResults WHERE Field3 Like '*.jpg' OR Field1 Is Not Null OR Field2 Is Not Null) AS Q5,
(SELECT COUNT(ID) as F FROM RelevantResults WHERE Field3 Like '*.jpg') AS Q6;
插入查询:
StrSQL = "INSERT INTO metrics (Filename, Field1, Field2, Field3, Field4, Field5, Field6)
Select '" & strFile & "', QryMetrics.* from QryMetrics;"
我在 VB 中使用 DoCmd.RunSQL 执行插入查询。
DoCmd.RunSQL StrSQL
当我尝试在数据库中仅针对 6 个字段运行查询时:我遇到了一个错误:插入语句包含以下未知字段名称:'A'
INSERT INTO metrics (Field1, Field2, Field3, Field4, Field5, Field6)
select * from qryMetrics
对此有什么想法吗?谢谢