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

powershell Start-Process exit code -1073741502 when used with Credential from a windows service environment -

twig - Using Twigbridge in a Laravel 5.1 Package -

c# - LINQ join Entities from HashSet's, Join vs Dictionary vs HashSet performance -