Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/ms-access/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql 使用ConcatRelated()和2个Where条件_Sql_Ms Access_Concatenation_Ms Access 2013 - Fatal编程技术网

Sql 使用ConcatRelated()和2个Where条件

Sql 使用ConcatRelated()和2个Where条件,sql,ms-access,concatenation,ms-access-2013,Sql,Ms Access,Concatenation,Ms Access 2013,我在一个查询中运行它-当我实际运行查询时,它会抛出一个错误 错误3061-参数太少。预期1 这是我的语法: SELECT [ExcelImport].[unitID], [ExcelImport].Department, ConcatRelated('[OrderID]','[ExcelImport]','[unitID] = ' & [unitID] & ' AND [Department] = ''' & [Department]) AS [SID] GROUP B

我在一个查询中运行它-当我实际运行查询时,它会抛出一个错误

错误3061-参数太少。预期1

这是我的语法:

SELECT [ExcelImport].[unitID], [ExcelImport].Department, 
ConcatRelated('[OrderID]','[ExcelImport]','[unitID] = ' & [unitID] & ' AND [Department] = ''' & [Department]) AS [SID]
GROUP BY [ExcelImport].[unitID], [ExcelImport].[Department]
ORDER BY [ExcelImport].[unitID];
这是使用Allen Browne的ConcatRelated()函数


引号和撇号用作特殊字符时必须始终成对使用。如果您发现很难确定配对是否正确,请使用引号来定义参数和文本分隔符的撇号。在[部门]后面需要一个结束撇号分隔符:

SELECT [ExcelImport].[unitID], [ExcelImport].Department, 
ConcatRelated("[OrderID]","[ExcelImport]","[unitID] = " & [unitID] & " AND [Department] = '" & [Department] & "'") AS [SID]
GROUP BY [ExcelImport].[unitID], [ExcelImport].[Department]
ORDER BY [ExcelImport].[unitID];

引号和撇号用作特殊字符时必须始终成对使用。如果您发现很难确定配对是否正确,请使用引号来定义参数和文本分隔符的撇号。在[部门]后面需要一个结束撇号分隔符:

SELECT [ExcelImport].[unitID], [ExcelImport].Department, 
ConcatRelated("[OrderID]","[ExcelImport]","[unitID] = " & [unitID] & " AND [Department] = '" & [Department] & "'") AS [SID]
GROUP BY [ExcelImport].[unitID], [ExcelImport].[Department]
ORDER BY [ExcelImport].[unitID];

unitID是整数,department是string如果我在department=''之后添加三个单引号,那么我会在查询表达式中的字符串中出现语法错误调试错误-我编辑了OP以反映更新的SYNATXY,您还需要通过添加
&'
来关闭department之后的三个单引号。unitID是整数,department是string如果我在department=''之后添加三个单引号,那么我会在查询表达式中的字符串中出现语法错误的调试错误-我编辑了OP以反映更新的语法。您还需要通过添加
&''来关闭department之后的三个单引号。