我有两张桌子。 “RPT_CHG”和“OPTIONS”。在RPT_CHG中,如果可以在表OPTIONS字段[ApplyToProductCodes]中找到字段[USER2]那么我希望它在[ApplyToPRoductCodes]中返回包含[USER2]的ID列表
(即
RPT_CHG字段[USER2] = ICE-GEM0450A
选项字段[ApplyToProductCodes]有两条记录,其中包含ICE-GEM0450A。
ID#36756包含
的 ICE-GEM0450A 下,ICE-GEM0450W,ICE-GEM0650A,ICE-GEM0650W,ICE-GEM0956A,ICE-GEM0956W,ICE-ICE0250FA,ICE-ICE0250FT,ICE-ICE0250FW,ICE-ICE0250HA,ICE-ICE0250HT ,ICE-ICE0250HW,ICE-ICE0320FA,ICE-ICE0320FW,ICE-ICE0320HA,ICE-ICE0320HW,ICE-ICE0400FA,ICE-ICE0400FT,ICE-ICE0400FW,ICE-ICE0400HA,ICE-ICE0400HT,ICE-ICE0400HW,ICE-ICE0406FA,ICE -ICE0406FW,ICE-ICE0406HA,ICE-ICE0406HW,ICE-ICE0500FA,ICE-ICE0500FT,ICE-ICE0500FW,ICE-ICE0500HA,ICE-ICE0500HT,ICE-ICE0500HW,ICE-ICE0520FA,ICE-ICE0520FW,ICE-ICE0520HA,ICE-ICE0520HW ,ICE-ICE0606FA,ICE-ICE0606FT,ICE-ICE0606FW,ICE-ICE0606HA,ICE-ICE0606HT,ICE-ICE0606HW,ICE-ICE0806FA,ICE-ICE0806FW,ICE-ICE0806HA,ICE-ICE0806HW,ICEO-GEM0450A,ICEO-GEM0650A,ICEO -GEM0956A,ICEO-ICE0250FA,ICEO-ICE0250HA,ICEO-ICE0320FA,ICEO-ICE0320HA,ICEO-ICE0400FA,ICEO-ICE0400HA,ICEO-ICE0500FA,ICEO-ICE0500HA,ICEO-ICE0520FA,ICEO-ICE0520HA,ICEO-ICE0606FA,ICEO-ICE0606HA ,ICEO-ICE0806FA,ICEO-ICE0806HA
ID#36757包含
ICE-GEM0450W,的 ICE-GEM0450A 下,ICE-GEM0650W,ICE-GEM0956W,ICE-ICE0250FT,ICE-ICE0250FW,ICE-ICE0250HT,ICE-ICE0250HW,ICE-ICE0320FA,ICE-ICE0320FW,ICE-ICE0320HA ,ICE-ICE0320HW,ICE-ICE0400FT,ICE-ICE0400FW,ICE-ICE0400HT,ICE-ICE0400HW,ICE-ICE0406FA,ICE-ICE0406FW,ICE-ICE0406HA,ICE-ICE0406HW,ICE-ICE0500FT,ICE-ICE0500FW,ICE-ICE0500HT,ICE -ICE0500HW,ICE-ICE0520FA,ICE-ICE0520FW,ICE-ICE0520HA,ICE-ICE0520HW,ICE-ICE0606FT,ICE-ICE0606FW,ICE-ICE0606HT,ICE-ICE0606HW,ICE-ICE0806FW,ICE-ICE0806HW,ICE-ICE1006FW,ICE-ICE1007FW ,ICE-ICE1007HA,ICE-ICE1007HW,ICE-ICE1406FA,ICE-ICE1406FW,ICE-ICE1406HA,ICE-ICE1406HW,ICE-ICE1407FA,ICE-ICE1407FW,ICE-ICE1407HA,ICE-ICE1407HW,ICE-ICE1806FW,ICE-ICE1806HW,ICE -ICE1807FW,ICE-ICE1807HW,ICE-ICE2106FW,ICE-ICE2106HW,ICE-ICE2107FW,ICE-ICE2107HW,ICE-MFI0500W,ICE-MFI0800W,ICE-MFI1256W,ICEO-GEM0450A,ICEO-GEM0650A,ICEO-GEM0956A,ICEO-ICE0250FA ,ICEO-ICE0250HA,ICEO-ICE0320FA,ICEO-ICE0320HA,ICEO-ICE0400FA,ICEO-ICE0400HA,ICEO-ICE0500FA,ICEO-ICE0500HA,ICEO-ICE0520FA,ICEO-ICE0520HA, ICEO-ICE0606FA,ICEO-ICE0606HA,ICEO-ICE0806FA,ICEO-ICE0806HA,ICEO-ICE1006FA,ICEO-ICE1006HA,ICEO-ICE1406FA,ICEO-ICE1406HA,ICEO-ICE1806FW,ICEO-ICE1806HW,ICEO-ICE2106FW,ICEO-ICE2106HW,ICEO- MFI0500A,ICEO-MFI0800A,ICEO-MFI1256A
所以我的查询会吐出来
ID
36756
36757
我尝试了几种可能的方法,似乎没有一种方法可以做我想要的。
我试过了:
ID:DLookUp("[ID]","OPTIONS","[USER2]" Like [ApplyToProductCodes])
这并没有给第一个可用记录提供大约1300条记录的预期结果。我错过了什么?我应该使用不同的方法吗?请指教。谢谢!
答案 0 :(得分:0)
我认为这是您寻求的查询:
SELECT RPT_CHG.USER2, OPTIONS.ID
FROM RPT_CHG, OPTIONS
WHERE (((OPTIONS.ApplyToProductCodes) Like "*" & [RPT_CHG].[USER2] & "*"));
基于我的(略微修改过的)测试数据,它返回
USER2 ID
--------------- -----
ICE-GEM0450A 36756
ICE-GEM0450A 36757
IAMSOSMART-SMRT 36757