php - Clubbing several similar repeating mysql SELECT statements -


i want fetch classified details table. have classified_ids in csv format. break them out csv , make independent queries every classified_id.

what doing right is:

select * classified classified_id = 501;  select * classified classified_id = 545;  select * classified classified_id = 578; 

..... , on... executing each 1 of them.

i feel inefficient large number of ids. there better way club of these statements 1 or make more efficient somehow?

[i using php mysql* (i know deprecated, old project)]

thanks in advance.

instead create array of classified_id like,

$classified_ids = [545, 123, 234]; 

and query using mysql in like,

$query = "select * classified classified_id in ( {implode(',', $classified_ids)} )"; 

will query,

$query = "select * classified classified_id in ( 545, 123, 234 )"; 

Comments

Popular posts from this blog

twig - Using Twigbridge in a Laravel 5.1 Package -

jdbc - Not able to establish database connection in eclipse -

firemonkey - How do I make a beep sound in Android using Delphi and the API? -