查找查询故障之间的差异?

时间:2019-06-25 18:40:38

标签: sql database vba ms-access

我有一系列查询,由于某种原因,当我做最后一个查询时,它会将该字段中的所有名称切换为数字,这些数字不是其表中的键或任何我可以理解的键。我发现查询之间的差异,然后将它们合并在一起以查看两组之间的差异总量。

 SELECT [MD/SA].[MD/SA Number], Junction.[Part Number], Junction.Quantity, 
 Junction.Designator
 FROM [MD/SA] INNER JOIN Junction ON [MD/SA].ID = Junction.[MD/SA Number]
 WHERE ((([MD/SA].[MD/SA Number])=[Insert Number 1:]));

Dif1 ^

 SELECT [MD/SA].[MD/SA Number], Junction.[Part Number], Junction.Quantity, 
 Junction.Designator
 FROM [MD/SA] INNER JOIN Junction ON [MD/SA].ID = Junction.[MD/SA Number]
 WHERE ((([MD/SA].[MD/SA Number])=[Insert Number 2:]));

Dif2 ^

 SELECT Dif1.[MD/SA Number], Dif1.[Part Number], Dif1.Quantity, 
 Dif1.Designator
 FROM Dif1 LEFT JOIN Dif2 ON Dif1.[Part Number] = Dif2.[Part Number]
 WHERE (((Dif2.[Part Number]) Is Null));

 MD/SA Number    Part Number            Quantity    Designator
 MD1907201B      B32674D6105K           2   C1, C2
 MD1907201B      DEBE33D222ZA2B         1   C3
 MD1907201B      STTH810FP              1   D1
 MD1907201B      031201.5MXP            1   F1
 MD1907201B      HSS-B20-NP-12          2   Heatsink
 MD1907201B      92005A114              2   M3 Heasink Screw
 MD1907201B      90592A085              2   M3 Heatsink Nut
 MD1907201B      HF115AC-0.0055-AC-54   2   Thermal Pad
 MD1907201B      90272A144              4   6-32 Screw
 MD1907201B      7587k431               1   "6"" Red wire"
 MD1907201B      7587k64                1   "6"" Black wire"

 SELECT Dif2.[MD/SA Number], Dif2.[Part Number], Dif2.Quantity, 
 Dif2.Designator
 FROM Dif2 LEFT JOIN Dif1 ON Dif2.[Part Number] = Dif1.[Part Number]
 WHERE (((Dif1.[Part Number]) Is Null));

 MD/SA Number   Part Number      Quantity   Designator
 MD1907201A     R463R410000M1K   2          C1, C2
 MD1907201A     1N4007-TP        1          D1
 MD1907201A     3AG7-R           1          F1
 MD1907201A     FC-102-22        2          F1 (Fuse Holder)
 MD1907201A     634-10ABPE       2          Heatsink
 MD1907201A     90272A143        10         6-32 Screw
 MD1907201A     90272A106        2          4-40 Screw
 MD1907201A     92319A634        4          6-32 Standoff
 MD1907201A     455-1319-1-ND    2          J1 Mating Pins
 MD1907201A     8054T26          1          "6"" Red Wire"
 MD1907201A     8054T26          1          "6"" Black Wire"

 SELECT Dif1.[MD/SA Number], Dif1.[Part Number], Dif1.Quantity, 
 Dif1.Designator
 FROM Dif1 LEFT JOIN Dif2 ON Dif1.[Part Number] = Dif2.[Part Number]
 WHERE (((Dif2.[Part Number]) Is Null))
 UNION ALL SELECT Dif2.[MD/SA Number], Dif2.[Part Number], Dif2.Quantity, 
 Dif2.Designator
 FROM Dif2 LEFT JOIN Dif1 ON Dif2.[Part Number] = Dif1.[Part Number]
 WHERE (((Dif1.[Part Number]) Is Null));

 MD/SA Number   Part Number Quantity    Designator
 MD1907201A     61          2           C1, C2
 MD1907201A     62          1           D1
 MD1907201A     63          1           F1
 MD1907201A     64          2           F1 (Fuse Holder)
 MD1907201A     65          2           Heatsink
 MD1907201A     66          10          6-32 Screw
 MD1907201A     67          2           4-40 Screw
 MD1907201A     68          4           6-32 Standoff
 MD1907201A     69          2           J1 Mating Pins
 MD1907201A     70          1           "6"" Red Wire"
 MD1907201A     70          1           "6"" Black Wire"
 MD1907201B     36          2           C1, C2
 MD1907201B     37          1           C3
 MD1907201B     39          1           D1
 MD1907201B     41          1           F1
 MD1907201B     53          2           Heatsink
 MD1907201B     54          2           M3 Heasink Screw
 MD1907201B     55          2           M3 Heatsink Nut
 MD1907201B     56          2           Thermal Pad
 MD1907201B     57          4           6-32 Screw
 MD1907201B     58          1           "6"" Red wire"
 MD1907201B     59          1           "6"" Black wire"

我希望输出的零件号标题下有实际的零件号,而我得到的编号却没有出现在数据库中的任何地方。

0 个答案:

没有答案