Php mysql选择具有多个WHERE的查询
我需要根据ID在一个查询中选择几行,例如下面是我写的Php mysql选择具有多个WHERE的查询,php,mysql,Php,Mysql,我需要根据ID在一个查询中选择几行,例如下面是我写的 SELECT * FROM posts WHERE post_id = "15 , 14 , 14" 如何在真正的sql查询中执行此操作?使用或/和where条件。比如: SELECT * FROM posts WHERE post_id IN (14,15); SELECT * FROM posts WHERE post_id = '13' OR post_id = '14' OR post_id = '15' 您还可以使用: SEL
SELECT * FROM posts WHERE post_id = "15 , 14 , 14"
如何在真正的sql查询中执行此操作?使用或/和where条件。比如:
SELECT * FROM posts WHERE post_id IN (14,15);
SELECT * FROM posts WHERE post_id = '13' OR post_id = '14' OR post_id = '15'
您还可以使用:
SELECT * FROM posts WHERE post_id BETWEEN 14 and 15
速度最快且效率更高的选项:
SELECT * FROM posts WHERE post_id IN (14,15)
但是,使用说明或并没有错
SELECT * FROM posts WHERE post_id = 14 OR post_id = 15
SELECT * FROM posts WHERE post_id = 14 OR post_id = 15