如何在mysqli_query中有多个WHERE值?

时间:2013-07-10 14:47:02

标签: php where

我如何在mysqli_query的WHERE中使用多个值?

离。

mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id = 3013, 4140, 6850")

这是使用多个WHERE值的正确方法吗?或...?

4 个答案:

答案 0 :(得分:4)

使用IN

WHERE post_id IN (3013, 4140, 6850)

相同
WHERE post_id = 3013 OR
      post_id = 4140 OR
      post_id = 6850

答案 1 :(得分:0)

您需要使用IN子句。

mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")

答案 2 :(得分:0)

使用IN

mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")

答案 3 :(得分:0)

首先,您应该查看文档:

select syntax

您将where子句与ANDOR

分开