2017-11-04 91 views
0

我在查詢運行這一點 - 當我實際運行查詢使用ConcatRelated()隨着2其中標準

錯誤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布朗的ConcatRelated()函數

http://allenbrowne.com/func-concat.html

使用時
+0

的UnitID是整數,部門串 – BellHopByDayAmetuerCoderByNigh

+0

如果我以後添加三聯單引號部=「」」然後我得到語法錯誤的調試錯誤在查詢表達式字符串 - 我編輯了我的操作系統以反映更新的synatx – BellHopByDayAmetuerCoderByNigh

+0

您需要在部門之後關閉三重引號,並添加'&''''。 – Alan

回答

2

行情,撇號必須始終成對特殊字符。如果您難以發現配對是否正確,請使用引號來定義文本分隔符的參數參數和撇號。需要[處]開始一撇號分隔符:

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];