我如何在mysqli_query的WHERE中使用多个值?
离。
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id = 3013, 4140, 6850")
这是使用多个WHERE值的正确方法吗?或...?
答案 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)