我将如何在 mysqli_query 的 WHERE 中使用多个值?
前任。
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id = 3013, 4140, 6850")
这是使用多个 WHERE 值的正确方法吗?或者...?
利用IN
WHERE post_id IN (3013, 4140, 6850)
这与
WHERE post_id = 3013 OR
post_id = 4140 OR
post_id = 6850
使用IN
:
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")
您需要使用IN
子句。
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")