【发布时间】:2017-07-30 22:20:06
【问题描述】:
我已在 Excel 文件中打印出文件和文件夹的目录。目录末尾的文件夹名称与 Excel 文件中另一列中的别名匹配。
我正在尝试使用右连接将它们连接在一起。这是使用 Excel 文件作为链接表的 Access,我正在尝试根据它们在一个文件中的别名列出目录。
当我尝试获取一列中的值的 Len 并将其放入查询中时,我收到语法错误连接错误。
这里是查询。不知道是否需要使用子串?
SELECT [General Acccounts].[Account #], [General Acccounts].[Account Name],
[General Acccounts].[Customer Alias], [General Acccounts].[Start Date]
FROM EOM_On_Hand_Counter LEFT JOIN [General Acccounts] ON
Right(EOM_On_Hand_Counter.DirectoryName,)(len([General Accounts].[Customer
Alias])) = [General Acccounts].[Customer Alias]
GROUP BY [General Acccounts].[Account #], [General Acccounts].[Account Name], [General Acccounts].[Customer Alias], [General Acccounts].[Start Date];
您可以看到我想将目录名称的右侧连接到一般帐户表中的客户别名值,因为它们匹配。当我在 Access 中使用 Len 函数时,它在 SQL 查询中不起作用。有人有什么建议吗?
【问题讨论】:
-
删除
Right()函数中逗号后的右括号和左括号。 -
@Parfait 试过这个,它说 Syntax Error In Join Operation 。我在逗号之后删除了 ( 并做了 len 运算符。
SELECT [General Acccounts].[Account #], [General Acccounts].[Account Name], [General Acccounts].[Customer Alias] FROM [General Acccounts] INNER JOIN EOM_On_Hand_Counter ON [General Acccounts].[Customer Alias] = right(EOM_On_Hand_Counter.DirectoryName,Len([General Accounts].[Account Name])) GROUP BY [General Acccounts].[Account #], [General Acccounts].[Account Name], [General Acccounts].[Customer Alias] -
请提供两个表的示例数据,以便我们重现。
-
@Parfait
EOM_On_Hand_Counter.DiretoryName = S:\admins\EOM\Tyco / [General Accounts].[Customer Alias] = Tyco我正在尝试将客户别名的长度与目录名称右侧相匹配。由于它们都是 4 我需要客户别名的长度。EOM_On_Hand_Counter.DirectoryName = S:\admins\EOM\Sprint / [General Accounts].[Customer Alias] = Sprint所以你可以看到我想匹配那个正确的六个字符。基本上客户别名是与结束目录名称相同的正确字符。 -
请用数据编辑帖子。在 cmets 中很难阅读。