这是我当前的表格。
WeldingProcedure
ID TYPE Metal1 Metal2 ThicknessMin ThicknessMax
50-1 SMAW 1 2 1 2
50-2 SAW 2 2 3 5
51-3 FCAW 3 2 2 6
52-1 SMAW 1 2 0.5 2
我当前的查询是
SELECT *
FROM WeldingProcedure as WPS
WHERE WPS.[Metal#(P-No)]=Forms!MatchSearch_form!metal1
And WPS.[Metal#2(P-No)]=Forms!MatchSearch_form!metal2
And WPS.ThicknessMin<=Forms!MatchSearch_form!thickness
And WPS.ThicknessMax>=Forms!MatchSearch_form!thickness
And WPS.[Welding _Type]=Forms!MatchSearch_form!weldingtype
所以当我使用以下标准搜索时:
Type = SMAW
Metal1 = 1
Metal2 = 2
Thickness = 1.5
我得到
的结果ID TYPE Metal1 Metal2 ThicknessMin ThicknessMax
50-1 SMAW 1 2 1 2
52-1 SMAW 1 2 0.5 2
我希望用户也可以键入
Type = SMAW
Metal1 = 2
Metal2 = 1
Thickness = 1.5
得到相同的结果。我该怎么做才能更改查询以实现这一目标?如果我将值键入两次,它会对表格进行整理。
答案 0 :(得分:1)
SELECT *
FROM WeldingProcedure as WPS
WHERE ((WPS.[Metal#(P-No)] = Forms!MatchSearch_form!metal1 AND WPS.[Metal#2(P-No)] = Forms!MatchSearch_form!metal2) OR (WPS.[Metal#(P-No)] = Forms!MatchSearch_form!metal2 AND WPS.[Metal#2(P-No)] = Forms!MatchSearch_form!metal1))
AND WPS.ThicknessMin<=Forms!MatchSearch_form!thickness
AND WPS.ThicknessMax>=Forms!MatchSearch_form!thickness
AND WPS.[Welding _Type]=Forms!MatchSearch_form!weldingtype
答案 1 :(得分:1)
如果我理解正确,您希望用户输入2个值并返回Metal1和Metal2等于这两个值的记录,但用户可以按任意顺序输入值(即输入Metal1然后输入Metal2或输入Metal2然后金属1)。
如果是这种情况,那么这就是您想要的查询。
SELECT *
FROM WeldingProcedure as WPS
WHERE
(
(WPS.[Metal#(P-No)]=Forms!MatchSearch_form!metal1 And WPS.[Metal#2(P-No)]=Forms!MatchSearch_form!metal2)
OR
(WPS.[Metal#(P-No)]=Forms!MatchSearch_form!metal2 And WPS.[Metal#2(P-No)]=Forms!MatchSearch_form!metal1)
)
And WPS.ThicknessMin<=Forms!MatchSearch_form!thickness
And WPS.ThicknessMax>=Forms!MatchSearch_form!thickness
And WPS.[Welding _Type]=Forms!MatchSearch_form!weldingtype