Select multiple records by one query
Posted
by kofto4ka
on Stack Overflow
See other posts from Stack Overflow
or by kofto4ka
Published on 2010-05-31T15:57:34Z
Indexed on
2010/05/31
16:03 UTC
Read the original article
Hit count: 183
mysql
Hello there. Please, give me advice, how to construct select query. I have table table
with fields type
and obj_id
. I want to select all records in concordance with next array:
$arr = array(
0 => array('type' => 1, 'obj_id' => 5),
1 => array('type' => 3, 'obj_id' => 15),
2 => array('type' => 4, 'obj_id' => 14),
3 => array('type' => 12, 'obj_id' => 17),
);
I want to select needed rows by one query, is it real? Smth like
select * from `table` where type in (1,3,4,12) and obj_id in (5,15,14,17)
But this query returns also records with type = 3 and obj_id = 14, and for example type = 1 and obj_id = 17. p.s. moderators, please fix my title, I dont know how to describe my question.
© Stack Overflow or respective owner