making mysql query using splite string?

Posted by Marco on Stack Overflow See other posts from Stack Overflow or by Marco
Published on 2012-10-03T03:35:00Z Indexed on 2012/10/03 3:37 UTC
Read the original article Hit count: 88

Filed under:
|
|

lets say i have a group of number like (3,2,5) the normal way i use to split them and searching mysql to get value is to split them using explode in PHP

EXAMPLE

$string = '3,4,5';
$array = explode(',',$string);
foreach($array as $value){
    $query = 'SELECT ID FROM TABLE WHERE ID = "'.$value.'"';
}

it work like this but it make the script extremely slow

i need now if there is away to split this string into the query it self and return the result without looping with PHP ?

© Stack Overflow or respective owner

Related posts about php

Related posts about mysql