根据Hogan的答案以及这篇MSDN文章,我已经对此进行了SQL语句编辑(如下),但是MS Query仍然不满意。
SELECT CO.MATERIALS1 AS 'Material',
CO.`SIZES#1` AS 'Size',
CO.`TOOLS#1` AS 'Tool',
IR.`BODY /JAW` AS 'BodyJaw',
IR.PN AS 'PartNo'
FROM {oj `COMBINATIONS$` CO
LEFT OUTER JOIN `'INSERTS REVIEW$'` IR
ON [IR.TOOL LIKE '% ' CO.`TOOLS#1` ' %']
AND [IR.SIZE LIKE '% ' CO.`SIZES#1` ' %']
AND [IR.MATERIAL LIKE '% ' CO.MATERIALS1 ' %']}
MS Query的语法似乎与我过去使用过的标准SQL / T-SQL略有不同,并且我正在努力弄清它想要什么。
上面的查询为我提供了有关期望联接运算符的错误:
我试图去掉花括号{ }
,它抱怨桌子oj:
我尝试删除该oj
参考,但它抱怨括号无效:
And in frustration I tried removing all brackets, and that makes it complain about a missing operator syntax error:
Aside from that, I've tried quite a few variations on structure, escape characters, concatenation characters, etc. I feel like I'm just spinning my wheels here with MS Query, and hoping that someone more versed in the nuances of MSQ could point out where I'm going wrong, and help me make it right.
I want to do a left join on the CO table, matching size, tool, and material on the IR table:
Which should yield this result:
另外,我意识到这将返回“ P12”和“ JP12 ”上的“ P12”的匹配项,但这并不是真正想要的行为,但是我觉得一旦使这个基本查询生效,我就可以解决该问题。如果需要,我可以在该字段的每个记录中添加一个前导或尾随的“ /”,这样我就可以匹配“ LIKE'%/'”之类的东西。
下面的ms查询将为您提供准确的结果。我尝试使用示例数据,并附上了屏幕截图。
SELECT CO.TOOL, CO.Material, CO.SIZE, IR.PN , IR.`BODY/JAW`
FROM `G:\test1.xlsx`.`COMBINATIONS$` CO
LEFT JOIN `G:\test1.xlsx`.`'INSERTS REVIEW$'` IR
ON CO.TOOL=IR.TOOL
AND ((IR.MATERIAL Like '%'+CO.Material+'%'))
AND ((IR.SIZE Like '%'+CO.Size+'%'))
测试数据显示在下面的屏幕截图中。
以下屏幕截图包含您想要的ms查询和结果。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句