-1

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

前任。

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

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

4

4 回答 4

4

利用IN

WHERE post_id IN (3013, 4140, 6850)

这与

WHERE post_id = 3013 OR
      post_id = 4140 OR
      post_id = 6850
于 2013-07-10T14:47:54.660 回答
0

使用IN

mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")
于 2013-07-10T14:48:58.970 回答
0

首先,您应该检查文档:

选择语法

你用ANDor分隔你的 where 子句OR

于 2013-07-10T14:49:16.870 回答
0

您需要使用IN子句。

mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")
于 2013-07-10T14:48:34.610 回答