Access 2010 SQL Query无法添加多个表单选项

时间:2018-01-30 16:19:32

标签: sql ms-access

我想改变这个SQL查询,不仅仅是读取几种形式![价格]!

SELECT Option.Index, Option.Desc, Option.Price, Option.Price_ext, 
       Product.ID, OptionGroup.Option
FROM Product 
INNER JOIN (OptionGroup INNER JOIN [Option] ON OptionGroup.ID = Option.OptionGrp) 
  ON Product.ID = OptionGroup.Product
WHERE (((Product.ID)=[Forms]![Prices]![selName2]) AND ((OptionGroup.Option)="F"))
ORDER BY Option.Index;

任何人都可以帮忙吗?

1 个答案:

答案 0 :(得分:0)

如评论所述,请考虑在IN()子句中使用WHERE运算符和逗号分隔的项,这相当于多个OR语句。并确保打开/关闭括号如下所示匹配夸张的缩进:

SELECT o.[Index], o.Desc, o.Price, o.Price_ext, 
       p.ID, OptionGroup.Option
FROM Product p
INNER JOIN (OptionGroup INNER JOIN [Option] o ON OptionGroup.ID = o.OptionGrp) 
  ON p.ID = OptionGroup.Product
WHERE (
        (
          (p.ID) IN (
                     [Forms]![Prices]![selName2],
                     [Forms]![OtherForm1]![FieldName],
                     [Forms]![OtherForm2]![FieldName],
                     [Forms]![OtherForm3]![FieldName]
                    )
        )

        AND (
               (OptionGroup.[Option])='F'
            )
      )
ORDER BY o.[Index];