-7

我需要为以下问题构建查询字符串 -

  1. 仅显示批代码在 Sun 和 Jamnagar City 和 Reliance 上的记录。
  2. 仅显示批代码在 Sun 和 Jamnagar City、Reliance 和 TATA 上的记录。

我的每周访问表 -

batch_code    bday             duration          period_no          branch
B001          Sun                   1            2                  Jamnagar City
B001          Mon                   1            2                  Jamnagar City
B001          Tue                   1            2                  Jamnagar City
B002          Mon                 1.3            4                  TATA
B002          Mon                 1.3            4                  TATA
B003          Sun                   1            1                  Jamnagar City
B003          Mon                   1            1                  Jamnagar City
B004          Sun                   2            2                  Reliance
B004          Mon                   2            2                  Reliance
B004          Tue                   2            2                  Reliance
B005          Sun                   2            2                  TATA
B005          Mon                   2            2                  TATA
B005          Tue                   2            2                  TATA
B006          Sun                 1.3            4                  Jamnagar City
B007          Wed                 1.3            4                  Jamnagar City
4

1 回答 1

1
  1. SELECT * FROM YourTableName WHERE bday='Sun' AND (branch='Jamnagar City' OR branch='Reliance')

  2. SELECT * FROM YourTableName WHERE bday='Sun' AND (branch='Jamnagar City' OR branch='Reliance' OR branch='TATA')

我相信您可以使用 IN 命令,但我不肯定它是否适用于 Access。不过你可以试试。语法是:

SELECT * FROM YourTableName WHERE bday='Sun' AND branch IN ('Jamnagar City', 'Reliance', 'TATA')

于 2013-06-04T14:04:43.573 回答