MS Access中一个参数字段中的多个值

时间:2017-11-13 18:19:42

标签: sql ms-access

有没有办法使用参数查询在同一字段中以文本格式搜索多个值?理想情况下,弹出参数框,我可以用逗号分隔任意数量的值。例如,我将从字段“CPN'”中输入CAR1074,19-2140-4-0001等值。在参数框中。我尝试了以下查询,但没有得出任何结果。 (得到一张空白的结果表)

PARAMETERS [Enter CPN/M&E] Text (255);

SELECT PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.CPN,
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.MPN,
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.KEYWORD,
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[PO NUMBER],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[PO LINE NUMBER],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[PO RECEIVED DATE],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[PO SUPPLIER CODE],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[PO SUPPLIER NAME],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[PO RECEIPT STATION],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[PO SYSTEM],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[RO NUMBER],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[RO LINE NUMBER],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[RO RECEIVED DATE],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[RO SUPPLIER CODE],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[RO SUPPLIER NAME],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[RO RECEIPT STATION],
       PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.[RO SYSTEM]
FROM PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE
WHERE (((PROD_SUPLR_MGMT_SNBX_DB_CUSTOMS_DATABASE.CPN)=Instr("," & [CPN] & ",","," & [CPN] & ",")));

1 个答案:

答案 0 :(得分:0)

因此,在输入字符串中搜索CPN,如果找到,则位置大于0。

WHERE InStr([Enter CPN/M&E, separate multiple values by comma], [CPN])>0