Hi,

I have a MySQL database and an array with ID's. For example:
$q = array(4,7,9,34,12,3,...etc);
The ID count in array can be over 100. What's the best way to select only those rows matching those ID's in array? The usual
SELECT *
FROM table
WHERE ID = '$q[0]'
OR ID = '$q[1]'
OR ID = '$q[2]'
... etc
seems a bit wrong in this case. Does it decreases performance greatly if there are over 100 OR's in the statement? Maybe there is a better solution?

Thanks

$list=implode(",",$q);

$query=" SELECT * 
FROM table 
WHERE ID in ($list)";
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.