Page 1 of 1

What command to fetch primary key matches stored in array?

Posted: Tue Sep 21, 2004 12:09 pm
by voltrader
I have a search function that returns pk results in an array.

Is there a command to fetch those records from mysql in one go?

Or do I have to loop through the array and fetch individual records?

Posted: Tue Sep 21, 2004 12:14 pm
by Weirdan
you can use IN function:

Code: Select all

$query = 'select * from some_table where pk_column in(' . implode(',', $pk_array) . ')';
// then execute the query and fetch rows as usual...

Posted: Tue Sep 21, 2004 12:15 pm
by voltrader
thanks -- much appreciated!