I had a table like this
id | name
------------------
1 | SAM1
2 | SAM2
1 | SAM1
3 | SAM3
7 | SAM7
6 | SAM6
I need to show the results using this query
SELECT name,id FROM tblnameWHERE id IN (1,2,7,6,1)
and getting the following result
id | name
------------------
1 | SAM1
2 | SAM2
7 | SAM7
6 | SAM6
My problem is this skipped last id , ie 1 . I need something like this
id | name
------------------
1 | SAM1
2 | SAM2
7 | SAM7
6 | SAM6
1 | SAM1
With out using the loop query ( like follows ) any other method for doing this ?
$ids=array(1,2,7,6,1);
$i=0;
foreach($ids as $id){
$sql=mysql_query("SELECT * FROM tblname WHERE id=$id");
// Store value to array
}
Please help