How would I use multiple values in the WHERE of a mysqli_query??
ex.
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id = 3013, 4140, 6850")
Is that the correct way to use multiple WHERE values? or...?
How would I use multiple values in the WHERE of a mysqli_query??
ex.
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id = 3013, 4140, 6850")
Is that the correct way to use multiple WHERE values? or...?
use IN
WHERE post_id IN (3013, 4140, 6850)
which is the same with
WHERE post_id = 3013 OR
post_id = 4140 OR
post_id = 6850
You need to use IN
clause.
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")
Use IN
:
mysqli_query ($con, "SELECT post_title, post_content, post_date FROM posts WHERE post_id IN (3013, 4140, 6850)")
First you should check the documentation:
And you seperate your where clauses with AND
or OR