在SELECT中使用OR的Mysql PDO语句

时间:2017-01-22 19:25:12

标签: php mysql pdo

我想在下面的陈述中使用OR,在下面的陈述中我选择了一个ID_klant,但我想在2个不同的id上选择

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
 <modelVersion>4.0.0</modelVersion>
<groupId>cucumber-a</groupId>
<artifactId>cucumber-a</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>cucumber</name>
<description>Basic Playground for Cucumber</description>
<dependencies>

<dependency>
    <groupId>info.cukes</groupId>
    <artifactId>cucumber-junit</artifactId>
    <version>1.2.4</version>
    <scope>test</scope>
</dependency>

<dependency>
    <groupId>junit</groupId>
    <artifactId>junit</artifactId>
    <version>4.12</version>
    <scope>test</scope>
</dependency>

</dependencies>
<build>
 <sourceDirectory>src</sourceDirectory>
  <plugins>
     <plugin>
      <artifactId>maven-compiler-plugin</artifactId>
      <version>3.5.1</version>
     <configuration>
        <source>1.8</source>
        <target>1.8</target>
     </configuration>
    </plugin>
  </plugins>

1 个答案:

答案 0 :(得分:2)

您可以使用in检查列中是否包含一系列值。以下是您如何将它与占位符一起使用:

WHERE t10.ID_klant in (:ID_klant, :second_placeholder)

然后绑定:second_placeholder:ID_klant